
kernel.elf:     file format elf64-littleriscv


Disassembly of section .text:

0000000080200000 <_entry>:
    .section .text
    .globl _entry
_entry:
    add t0, a0, 1
    80200000:	00150293          	addi	t0,a0,1
    slli t0, t0, 14
    80200004:	02ba                	slli	t0,t0,0xe
    la sp, boot_stack
    80200006:	0000d117          	auipc	sp,0xd
    8020000a:	ffa10113          	addi	sp,sp,-6 # 8020d000 <boot_stack>
    add sp, sp, t0
    8020000e:	9116                	add	sp,sp,t0
    call main
    80200010:	00000097          	auipc	ra,0x0
    80200014:	12c080e7          	jalr	300(ra) # 8020013c <main>

0000000080200018 <loop>:

loop:
    j loop
    80200018:	a001                	j	80200018 <loop>

000000008020001a <contentSwitch>:
.globl contentSwitch
contentSwitch:
    sd ra, 0(a0)
    8020001a:	00153023          	sd	ra,0(a0)
    sd sp, 8(a0)
    8020001e:	00253423          	sd	sp,8(a0)
    sd s0, 16(a0)
    80200022:	e900                	sd	s0,16(a0)
    sd s1, 24(a0)
    80200024:	ed04                	sd	s1,24(a0)
    sd s2, 32(a0)
    80200026:	03253023          	sd	s2,32(a0)
    sd s3, 40(a0)
    8020002a:	03353423          	sd	s3,40(a0)
    sd s4, 48(a0)
    8020002e:	03453823          	sd	s4,48(a0)
    sd s5, 56(a0)
    80200032:	03553c23          	sd	s5,56(a0)
    sd s6, 64(a0)
    80200036:	05653023          	sd	s6,64(a0)
    sd s7, 72(a0)
    8020003a:	05753423          	sd	s7,72(a0)
    sd s8, 80(a0)
    8020003e:	05853823          	sd	s8,80(a0)
    sd s9, 88(a0)
    80200042:	05953c23          	sd	s9,88(a0)
    sd s10, 96(a0)
    80200046:	07a53023          	sd	s10,96(a0)
    sd s11, 104(a0)
    8020004a:	07b53423          	sd	s11,104(a0)
    

    ld ra, 0(a1)
    8020004e:	0005b083          	ld	ra,0(a1)
    ld sp, 8(a1)
    80200052:	0085b103          	ld	sp,8(a1)
    ld s0, 16(a1)
    80200056:	6980                	ld	s0,16(a1)
    ld s1, 24(a1)
    80200058:	6d84                	ld	s1,24(a1)
    ld s2, 32(a1)
    8020005a:	0205b903          	ld	s2,32(a1)
    ld s3, 40(a1)
    8020005e:	0285b983          	ld	s3,40(a1)
    ld s4, 48(a1)
    80200062:	0305ba03          	ld	s4,48(a1)
    ld s5, 56(a1)
    80200066:	0385ba83          	ld	s5,56(a1)
    ld s6, 64(a1)
    8020006a:	0405bb03          	ld	s6,64(a1)
    ld s7, 72(a1)
    8020006e:	0485bb83          	ld	s7,72(a1)
    ld s8, 80(a1)
    80200072:	0505bc03          	ld	s8,80(a1)
    ld s9, 88(a1)
    80200076:	0585bc83          	ld	s9,88(a1)
    ld s10, 96(a1)
    8020007a:	0605bd03          	ld	s10,96(a1)
    ld s11, 104(a1)
    8020007e:	0685bd83          	ld	s11,104(a1)

    80200082:	8082                	ret
	...

0000000080200090 <kernelvec>:
.globl kernel_trap
.globl kernelvec 
.align 4
kernelvec:
    addi sp, sp, -256
    80200090:	7111                	addi	sp,sp,-256
    sd ra, 0(sp)
    80200092:	e006                	sd	ra,0(sp)
    sd sp, 8(sp)
    80200094:	e40a                	sd	sp,8(sp)
    sd gp, 16(sp)
    80200096:	e80e                	sd	gp,16(sp)
    sd tp, 24(sp)
    80200098:	ec12                	sd	tp,24(sp)
    sd t0, 32(sp)
    8020009a:	f016                	sd	t0,32(sp)
    sd t1, 40(sp)
    8020009c:	f41a                	sd	t1,40(sp)
    sd t2, 48(sp)
    8020009e:	f81e                	sd	t2,48(sp)
    sd s0, 56(sp)
    802000a0:	fc22                	sd	s0,56(sp)
    sd s1, 64(sp)
    802000a2:	e0a6                	sd	s1,64(sp)
    sd a0, 72(sp)
    802000a4:	e4aa                	sd	a0,72(sp)
    sd a1, 80(sp)
    802000a6:	e8ae                	sd	a1,80(sp)
    sd a2, 88(sp)
    802000a8:	ecb2                	sd	a2,88(sp)
    sd a3, 96(sp)
    802000aa:	f0b6                	sd	a3,96(sp)
    sd a4, 104(sp)
    802000ac:	f4ba                	sd	a4,104(sp)
    sd a5, 112(sp)
    802000ae:	f8be                	sd	a5,112(sp)
    sd a6, 120(sp)
    802000b0:	fcc2                	sd	a6,120(sp)
    sd a7, 128(sp)
    802000b2:	e146                	sd	a7,128(sp)
    sd s2, 136(sp)
    802000b4:	e54a                	sd	s2,136(sp)
    sd s3, 144(sp)
    802000b6:	e94e                	sd	s3,144(sp)
    sd s4, 152(sp)
    802000b8:	ed52                	sd	s4,152(sp)
    sd s5, 160(sp)
    802000ba:	f156                	sd	s5,160(sp)
    sd s6, 168(sp)
    802000bc:	f55a                	sd	s6,168(sp)
    sd s7, 176(sp)
    802000be:	f95e                	sd	s7,176(sp)
    sd s8, 184(sp)
    802000c0:	fd62                	sd	s8,184(sp)
    sd s9, 192(sp)
    802000c2:	e1e6                	sd	s9,192(sp)
    sd s10, 200(sp)
    802000c4:	e5ea                	sd	s10,200(sp)
    sd s11, 208(sp)
    802000c6:	e9ee                	sd	s11,208(sp)
    sd t3, 216(sp)
    802000c8:	edf2                	sd	t3,216(sp)
    sd t4, 224(sp)
    802000ca:	f1f6                	sd	t4,224(sp)
    sd t5, 232(sp)
    802000cc:	f5fa                	sd	t5,232(sp)
    sd t6, 240(sp)
    802000ce:	f9fe                	sd	t6,240(sp)
    call kernel_trap
    802000d0:	00004097          	auipc	ra,0x4
    802000d4:	bda080e7          	jalr	-1062(ra) # 80203caa <kernel_trap>

    ld ra, 0(sp)
    802000d8:	6082                	ld	ra,0(sp)
    ld sp, 8(sp)
    802000da:	6122                	ld	sp,8(sp)
    ld gp, 16(sp)
    802000dc:	61c2                	ld	gp,16(sp)
    ld t0, 32(sp)
    802000de:	7282                	ld	t0,32(sp)
    ld t1, 40(sp)
    802000e0:	7322                	ld	t1,40(sp)
    ld t2, 48(sp)
    802000e2:	73c2                	ld	t2,48(sp)
    ld s0, 56(sp)
    802000e4:	7462                	ld	s0,56(sp)
    ld s1, 64(sp)
    802000e6:	6486                	ld	s1,64(sp)
    ld a0, 72(sp)
    802000e8:	6526                	ld	a0,72(sp)
    ld a1, 80(sp)
    802000ea:	65c6                	ld	a1,80(sp)
    ld a2, 88(sp)
    802000ec:	6666                	ld	a2,88(sp)
    ld a3, 96(sp)
    802000ee:	7686                	ld	a3,96(sp)
    ld a4, 104(sp)
    802000f0:	7726                	ld	a4,104(sp)
    ld a5, 112(sp)
    802000f2:	77c6                	ld	a5,112(sp)
    ld a6, 120(sp)
    802000f4:	7866                	ld	a6,120(sp)
    ld a7, 128(sp)
    802000f6:	688a                	ld	a7,128(sp)
    ld s2, 136(sp)
    802000f8:	692a                	ld	s2,136(sp)
    ld s3, 144(sp)
    802000fa:	69ca                	ld	s3,144(sp)
    ld s4, 152(sp)
    802000fc:	6a6a                	ld	s4,152(sp)
    ld s5, 160(sp)
    802000fe:	7a8a                	ld	s5,160(sp)
    ld s6, 168(sp)
    80200100:	7b2a                	ld	s6,168(sp)
    ld s7, 176(sp)
    80200102:	7bca                	ld	s7,176(sp)
    ld s8, 184(sp)
    80200104:	7c6a                	ld	s8,184(sp)
    ld s9, 192(sp)
    80200106:	6c8e                	ld	s9,192(sp)
    ld s10, 200(sp)
    80200108:	6d2e                	ld	s10,200(sp)
    ld s11, 208(sp)
    8020010a:	6dce                	ld	s11,208(sp)
    ld t3, 216(sp)
    8020010c:	6e6e                	ld	t3,216(sp)
    ld t4, 224(sp)
    8020010e:	7e8e                	ld	t4,224(sp)
    ld t5, 232(sp)
    80200110:	7f2e                	ld	t5,232(sp)
    ld t6, 240(sp)
    80200112:	7fce                	ld	t6,240(sp)

    addi sp, sp, 256
    80200114:	6111                	addi	sp,sp,256
    # ret 
    sret
    80200116:	10200073          	sret
	...

0000000080200122 <w_tp>:
#include "type.h"

//hartid
static inline void
w_tp(register_t hartid)
{
    80200122:	1101                	addi	sp,sp,-32
    80200124:	ec22                	sd	s0,24(sp)
    80200126:	1000                	addi	s0,sp,32
    80200128:	fea43423          	sd	a0,-24(s0)
    asm volatile("mv tp, %0"
                 :
                 : "r"(hartid & 0x1));
    8020012c:	fe843783          	ld	a5,-24(s0)
    80200130:	8b85                	andi	a5,a5,1
    asm volatile("mv tp, %0"
    80200132:	823e                	mv	tp,a5
}
    80200134:	0001                	nop
    80200136:	6462                	ld	s0,24(sp)
    80200138:	6105                	addi	sp,sp,32
    8020013a:	8082                	ret

000000008020013c <main>:
#include "fs/file.h"
#include "fs/fat32.h"

int start = 0;
int
main(register_t hartid) {
    8020013c:	1101                	addi	sp,sp,-32
    8020013e:	ec06                	sd	ra,24(sp)
    80200140:	e822                	sd	s0,16(sp)
    80200142:	1000                	addi	s0,sp,32
    80200144:	fea43423          	sd	a0,-24(s0)
    w_tp(hartid);
    80200148:	fe843503          	ld	a0,-24(s0)
    8020014c:	00000097          	auipc	ra,0x0
    80200150:	fd6080e7          	jalr	-42(ra) # 80200122 <w_tp>
    if (hartid == 0) {
    80200154:	fe843783          	ld	a5,-24(s0)
    80200158:	e7d1                	bnez	a5,802001e4 <main+0xa8>
        // setNextTime();
        console_init();
    8020015a:	00000097          	auipc	ra,0x0
    8020015e:	0be080e7          	jalr	190(ra) # 80200218 <console_init>
        printinit();
    80200162:	00002097          	auipc	ra,0x2
    80200166:	5de080e7          	jalr	1502(ra) # 80202740 <printinit>
        kinit();
    8020016a:	00000097          	auipc	ra,0x0
    8020016e:	494080e7          	jalr	1172(ra) # 802005fe <kinit>
        kvminit();
    80200172:	00000097          	auipc	ra,0x0
    80200176:	6a4080e7          	jalr	1700(ra) # 80200816 <kvminit>
        kvminithart();
    8020017a:	00001097          	auipc	ra,0x1
    8020017e:	9e2080e7          	jalr	-1566(ra) # 80200b5c <kvminithart>
        kmm_init();
    80200182:	00001097          	auipc	ra,0x1
    80200186:	a9c080e7          	jalr	-1380(ra) # 80200c1e <kmm_init>
        timerInit();
    8020018a:	00004097          	auipc	ra,0x4
    8020018e:	d26080e7          	jalr	-730(ra) # 80203eb0 <timerInit>
        trapinithart();
    80200192:	00003097          	auipc	ra,0x3
    80200196:	6b2080e7          	jalr	1714(ra) # 80203844 <trapinithart>
        proc_init();
    8020019a:	00002097          	auipc	ra,0x2
    8020019e:	98e080e7          	jalr	-1650(ra) # 80201b28 <proc_init>
        plicinit();
    802001a2:	00004097          	auipc	ra,0x4
    802001a6:	d50080e7          	jalr	-688(ra) # 80203ef2 <plicinit>
        plicinithart();
    802001aa:	00004097          	auipc	ra,0x4
    802001ae:	d84080e7          	jalr	-636(ra) # 80203f2e <plicinithart>
#ifndef QEMU
        fpioa_pin_init();
        dmac_init();
#endif
        disk_init();
    802001b2:	00007097          	auipc	ra,0x7
    802001b6:	748080e7          	jalr	1864(ra) # 802078fa <disk_init>
        file_init();
    802001ba:	00007097          	auipc	ra,0x7
    802001be:	4ac080e7          	jalr	1196(ra) # 80207666 <file_init>
      //  fat32_init();
        // TODO: fs init
        creat_first_proc();
    802001c2:	00002097          	auipc	ra,0x2
    802001c6:	c88080e7          	jalr	-888(ra) # 80201e4a <creat_first_proc>
        printf("hart0 init done\n");
    802001ca:	0000b517          	auipc	a0,0xb
    802001ce:	e3650513          	addi	a0,a0,-458 # 8020b000 <etext>
    802001d2:	00002097          	auipc	ra,0x2
    802001d6:	720080e7          	jalr	1824(ra) # 802028f2 <printf>
        scheduler();
    802001da:	00002097          	auipc	ra,0x2
    802001de:	e94080e7          	jalr	-364(ra) # 8020206e <scheduler>
    802001e2:	a011                	j	802001e6 <main+0xaa>
    } else {
        while (1)
    802001e4:	a001                	j	802001e4 <main+0xa8>
            ;
    }
    return 0;
    802001e6:	4781                	li	a5,0
    802001e8:	853e                	mv	a0,a5
    802001ea:	60e2                	ld	ra,24(sp)
    802001ec:	6442                	ld	s0,16(sp)
    802001ee:	6105                	addi	sp,sp,32
    802001f0:	8082                	ret

00000000802001f2 <sbi_putchar>:
#define SBI_CALL_3(which, arg0, arg1, arh2) \
        SBI_CALL(which, arg0, arg1, arg2, 0)
#define SBI_CALL_4(which, arg0, arg1, arg2, arg3)       \
        SBI_CALL(which, arg0, arg1, arg2, arg3)
static inline void sbi_putchar(int ch)
{
    802001f2:	1101                	addi	sp,sp,-32
    802001f4:	ec22                	sd	s0,24(sp)
    802001f6:	1000                	addi	s0,sp,32
    802001f8:	87aa                	mv	a5,a0
    802001fa:	fef42623          	sw	a5,-20(s0)
    SBI_CALL_1(SBI_PUTCHAR, ch);
    802001fe:	fec42783          	lw	a5,-20(s0)
    80200202:	853e                	mv	a0,a5
    80200204:	4581                	li	a1,0
    80200206:	4601                	li	a2,0
    80200208:	4681                	li	a3,0
    8020020a:	4885                	li	a7,1
    8020020c:	00000073          	ecall
}
    80200210:	0001                	nop
    80200212:	6462                	ld	s0,24(sp)
    80200214:	6105                	addi	sp,sp,32
    80200216:	8082                	ret

0000000080200218 <console_init>:
    uint32_t read;
    uint32_t write;
} console;

void
console_init(void) {
    80200218:	1141                	addi	sp,sp,-16
    8020021a:	e406                	sd	ra,8(sp)
    8020021c:	e022                	sd	s0,0(sp)
    8020021e:	0800                	addi	s0,sp,16
    spinlock_init(&console.lk, "console_lk");
    80200220:	0000b597          	auipc	a1,0xb
    80200224:	df858593          	addi	a1,a1,-520 # 8020b018 <etext+0x18>
    80200228:	00015517          	auipc	a0,0x15
    8020022c:	de050513          	addi	a0,a0,-544 # 80215008 <console>
    80200230:	00004097          	auipc	ra,0x4
    80200234:	6f2080e7          	jalr	1778(ra) # 80204922 <spinlock_init>
    console.read = 0;
    80200238:	00015797          	auipc	a5,0x15
    8020023c:	dd078793          	addi	a5,a5,-560 # 80215008 <console>
    80200240:	0807ac23          	sw	zero,152(a5)
    console.write = 0;
    80200244:	00015797          	auipc	a5,0x15
    80200248:	dc478793          	addi	a5,a5,-572 # 80215008 <console>
    8020024c:	0807ae23          	sw	zero,156(a5)
}
    80200250:	0001                	nop
    80200252:	60a2                	ld	ra,8(sp)
    80200254:	6402                	ld	s0,0(sp)
    80200256:	0141                	addi	sp,sp,16
    80200258:	8082                	ret

000000008020025a <console_putc>:
void
console_putc(int ch) {
    8020025a:	1101                	addi	sp,sp,-32
    8020025c:	ec06                	sd	ra,24(sp)
    8020025e:	e822                	sd	s0,16(sp)
    80200260:	1000                	addi	s0,sp,32
    80200262:	87aa                	mv	a5,a0
    80200264:	fef42623          	sw	a5,-20(s0)
    if (ch == BACKSPACE) {
    80200268:	fec42783          	lw	a5,-20(s0)
    8020026c:	0007871b          	sext.w	a4,a5
    80200270:	10000793          	li	a5,256
    80200274:	02f71363          	bne	a4,a5,8020029a <console_putc+0x40>
        sbi_putchar('\b');
    80200278:	4521                	li	a0,8
    8020027a:	00000097          	auipc	ra,0x0
    8020027e:	f78080e7          	jalr	-136(ra) # 802001f2 <sbi_putchar>
        sbi_putchar(' ');
    80200282:	02000513          	li	a0,32
    80200286:	00000097          	auipc	ra,0x0
    8020028a:	f6c080e7          	jalr	-148(ra) # 802001f2 <sbi_putchar>
        sbi_putchar('\b');
    8020028e:	4521                	li	a0,8
    80200290:	00000097          	auipc	ra,0x0
    80200294:	f62080e7          	jalr	-158(ra) # 802001f2 <sbi_putchar>
    } else {
        sbi_putchar((unsigned char)ch);
    }
}
    80200298:	a819                	j	802002ae <console_putc+0x54>
        sbi_putchar((unsigned char)ch);
    8020029a:	fec42783          	lw	a5,-20(s0)
    8020029e:	0ff7f793          	zext.b	a5,a5
    802002a2:	2781                	sext.w	a5,a5
    802002a4:	853e                	mv	a0,a5
    802002a6:	00000097          	auipc	ra,0x0
    802002aa:	f4c080e7          	jalr	-180(ra) # 802001f2 <sbi_putchar>
}
    802002ae:	0001                	nop
    802002b0:	60e2                	ld	ra,24(sp)
    802002b2:	6442                	ld	s0,16(sp)
    802002b4:	6105                	addi	sp,sp,32
    802002b6:	8082                	ret

00000000802002b8 <console_write>:

void
console_write(void* src, uint32_t IsUser, size_t size)  // size: byte
{
    802002b8:	7139                	addi	sp,sp,-64
    802002ba:	fc06                	sd	ra,56(sp)
    802002bc:	f822                	sd	s0,48(sp)
    802002be:	0080                	addi	s0,sp,64
    802002c0:	fca43c23          	sd	a0,-40(s0)
    802002c4:	87ae                	mv	a5,a1
    802002c6:	fcc43423          	sd	a2,-56(s0)
    802002ca:	fcf42a23          	sw	a5,-44(s0)
#ifdef DEBUG
    printf("console_write: src = %p, IsUser = %d, size = %d", src, IsUser, size);
    802002ce:	fd442783          	lw	a5,-44(s0)
    802002d2:	fc843683          	ld	a3,-56(s0)
    802002d6:	863e                	mv	a2,a5
    802002d8:	fd843583          	ld	a1,-40(s0)
    802002dc:	0000b517          	auipc	a0,0xb
    802002e0:	d4c50513          	addi	a0,a0,-692 # 8020b028 <etext+0x28>
    802002e4:	00002097          	auipc	ra,0x2
    802002e8:	60e080e7          	jalr	1550(ra) # 802028f2 <printf>
#endif
    spinlock_acquire(&console.lk);
    802002ec:	00015517          	auipc	a0,0x15
    802002f0:	d1c50513          	addi	a0,a0,-740 # 80215008 <console>
    802002f4:	00004097          	auipc	ra,0x4
    802002f8:	65e080e7          	jalr	1630(ra) # 80204952 <spinlock_acquire>
    if (IsUser) {
    802002fc:	fd442783          	lw	a5,-44(s0)
    80200300:	2781                	sext.w	a5,a5
    80200302:	cf8d                	beqz	a5,8020033c <console_write+0x84>
        //         panic("console_write");
        //         while(1);
        //     }
        //     sbi_putchar(ch);
        // }
        for(size_t i = 0; i < size; i++)
    80200304:	fe043423          	sd	zero,-24(s0)
    80200308:	a01d                	j	8020032e <console_write+0x76>
        {
            sbi_putchar(((byte_t*)src)[i]);
    8020030a:	fd843703          	ld	a4,-40(s0)
    8020030e:	fe843783          	ld	a5,-24(s0)
    80200312:	97ba                	add	a5,a5,a4
    80200314:	0007c783          	lbu	a5,0(a5)
    80200318:	2781                	sext.w	a5,a5
    8020031a:	853e                	mv	a0,a5
    8020031c:	00000097          	auipc	ra,0x0
    80200320:	ed6080e7          	jalr	-298(ra) # 802001f2 <sbi_putchar>
        for(size_t i = 0; i < size; i++)
    80200324:	fe843783          	ld	a5,-24(s0)
    80200328:	0785                	addi	a5,a5,1
    8020032a:	fef43423          	sd	a5,-24(s0)
    8020032e:	fe843703          	ld	a4,-24(s0)
    80200332:	fc843783          	ld	a5,-56(s0)
    80200336:	fcf76ae3          	bltu	a4,a5,8020030a <console_write+0x52>
    8020033a:	a825                	j	80200372 <console_write+0xba>
        }
    } else {
        for (size_t i = 0; i < size; i++) {
    8020033c:	fe043023          	sd	zero,-32(s0)
    80200340:	a01d                	j	80200366 <console_write+0xae>
            sbi_putchar(((byte_t*)src)[i]);
    80200342:	fd843703          	ld	a4,-40(s0)
    80200346:	fe043783          	ld	a5,-32(s0)
    8020034a:	97ba                	add	a5,a5,a4
    8020034c:	0007c783          	lbu	a5,0(a5)
    80200350:	2781                	sext.w	a5,a5
    80200352:	853e                	mv	a0,a5
    80200354:	00000097          	auipc	ra,0x0
    80200358:	e9e080e7          	jalr	-354(ra) # 802001f2 <sbi_putchar>
        for (size_t i = 0; i < size; i++) {
    8020035c:	fe043783          	ld	a5,-32(s0)
    80200360:	0785                	addi	a5,a5,1
    80200362:	fef43023          	sd	a5,-32(s0)
    80200366:	fe043703          	ld	a4,-32(s0)
    8020036a:	fc843783          	ld	a5,-56(s0)
    8020036e:	fcf76ae3          	bltu	a4,a5,80200342 <console_write+0x8a>
        }
    }
    spinlock_release(&console.lk);
    80200372:	00015517          	auipc	a0,0x15
    80200376:	c9650513          	addi	a0,a0,-874 # 80215008 <console>
    8020037a:	00004097          	auipc	ra,0x4
    8020037e:	64e080e7          	jalr	1614(ra) # 802049c8 <spinlock_release>
}
    80200382:	0001                	nop
    80200384:	70e2                	ld	ra,56(sp)
    80200386:	7442                	ld	s0,48(sp)
    80200388:	6121                	addi	sp,sp,64
    8020038a:	8082                	ret

000000008020038c <console_read>:

void
console_read(void* dst, uint32_t IsUser, size_t size) {
    8020038c:	7139                	addi	sp,sp,-64
    8020038e:	fc06                	sd	ra,56(sp)
    80200390:	f822                	sd	s0,48(sp)
    80200392:	0080                	addi	s0,sp,64
    80200394:	fca43c23          	sd	a0,-40(s0)
    80200398:	87ae                	mv	a5,a1
    8020039a:	fcc43423          	sd	a2,-56(s0)
    8020039e:	fcf42a23          	sw	a5,-44(s0)
    panic("console_read");
    802003a2:	0000b517          	auipc	a0,0xb
    802003a6:	cb650513          	addi	a0,a0,-842 # 8020b058 <etext+0x58>
    802003aa:	00002097          	auipc	ra,0x2
    802003ae:	75a080e7          	jalr	1882(ra) # 80202b04 <panic>
    byte_t ch;
    spinlock_acquire(&console.lk);
    802003b2:	00015517          	auipc	a0,0x15
    802003b6:	c5650513          	addi	a0,a0,-938 # 80215008 <console>
    802003ba:	00004097          	auipc	ra,0x4
    802003be:	598080e7          	jalr	1432(ra) # 80204952 <spinlock_acquire>
    while (size > 0) {
    802003c2:	a0e9                	j	8020048c <console_read+0x100>
        while (console.read == console.write) {
            sleep_spin(&console.read, &console.lk);
    802003c4:	00015597          	auipc	a1,0x15
    802003c8:	c4458593          	addi	a1,a1,-956 # 80215008 <console>
    802003cc:	00015517          	auipc	a0,0x15
    802003d0:	cd450513          	addi	a0,a0,-812 # 802150a0 <console+0x98>
    802003d4:	00002097          	auipc	ra,0x2
    802003d8:	f26080e7          	jalr	-218(ra) # 802022fa <sleep_spin>
        while (console.read == console.write) {
    802003dc:	00015797          	auipc	a5,0x15
    802003e0:	c2c78793          	addi	a5,a5,-980 # 80215008 <console>
    802003e4:	0987a703          	lw	a4,152(a5)
    802003e8:	00015797          	auipc	a5,0x15
    802003ec:	c2078793          	addi	a5,a5,-992 # 80215008 <console>
    802003f0:	09c7a783          	lw	a5,156(a5)
    802003f4:	fcf708e3          	beq	a4,a5,802003c4 <console_read+0x38>
        }
        ch = console.buf[console.read % BUFSIZE];
    802003f8:	00015797          	auipc	a5,0x15
    802003fc:	c1078793          	addi	a5,a5,-1008 # 80215008 <console>
    80200400:	0987a783          	lw	a5,152(a5)
    80200404:	07f7f793          	andi	a5,a5,127
    80200408:	2781                	sext.w	a5,a5
    8020040a:	00015717          	auipc	a4,0x15
    8020040e:	bfe70713          	addi	a4,a4,-1026 # 80215008 <console>
    80200412:	1782                	slli	a5,a5,0x20
    80200414:	9381                	srli	a5,a5,0x20
    80200416:	97ba                	add	a5,a5,a4
    80200418:	0187c783          	lbu	a5,24(a5)
    8020041c:	fef407a3          	sb	a5,-17(s0)
        console.read++;
    80200420:	00015797          	auipc	a5,0x15
    80200424:	be878793          	addi	a5,a5,-1048 # 80215008 <console>
    80200428:	0987a783          	lw	a5,152(a5)
    8020042c:	2785                	addiw	a5,a5,1
    8020042e:	0007871b          	sext.w	a4,a5
    80200432:	00015797          	auipc	a5,0x15
    80200436:	bd678793          	addi	a5,a5,-1066 # 80215008 <console>
    8020043a:	08e7ac23          	sw	a4,152(a5)
        if (IsUser) {
    8020043e:	fd442783          	lw	a5,-44(s0)
    80200442:	2781                	sext.w	a5,a5
    80200444:	cb91                	beqz	a5,80200458 <console_read+0xcc>
            printf("IsUser");
    80200446:	0000b517          	auipc	a0,0xb
    8020044a:	c2250513          	addi	a0,a0,-990 # 8020b068 <etext+0x68>
    8020044e:	00002097          	auipc	ra,0x2
    80200452:	4a4080e7          	jalr	1188(ra) # 802028f2 <printf>
            while (1)
    80200456:	a001                	j	80200456 <console_read+0xca>
                ;
        } else {
            memmove(dst, &ch, 1);
    80200458:	fef40793          	addi	a5,s0,-17
    8020045c:	4605                	li	a2,1
    8020045e:	85be                	mv	a1,a5
    80200460:	fd843503          	ld	a0,-40(s0)
    80200464:	00002097          	auipc	ra,0x2
    80200468:	718080e7          	jalr	1816(ra) # 80202b7c <memmove>
        }
        dst++;
    8020046c:	fd843783          	ld	a5,-40(s0)
    80200470:	0785                	addi	a5,a5,1
    80200472:	fcf43c23          	sd	a5,-40(s0)
        size--;
    80200476:	fc843783          	ld	a5,-56(s0)
    8020047a:	17fd                	addi	a5,a5,-1
    8020047c:	fcf43423          	sd	a5,-56(s0)
        if (ch == '\n')
    80200480:	fef44783          	lbu	a5,-17(s0)
    80200484:	873e                	mv	a4,a5
    80200486:	47a9                	li	a5,10
    80200488:	00f70663          	beq	a4,a5,80200494 <console_read+0x108>
    while (size > 0) {
    8020048c:	fc843783          	ld	a5,-56(s0)
    80200490:	f7b1                	bnez	a5,802003dc <console_read+0x50>
    80200492:	a011                	j	80200496 <console_read+0x10a>
            break;
    80200494:	0001                	nop
    }
    spinlock_release(&console.lk);
    80200496:	00015517          	auipc	a0,0x15
    8020049a:	b7250513          	addi	a0,a0,-1166 # 80215008 <console>
    8020049e:	00004097          	auipc	ra,0x4
    802004a2:	52a080e7          	jalr	1322(ra) # 802049c8 <spinlock_release>
}
    802004a6:	0001                	nop
    802004a8:	70e2                	ld	ra,56(sp)
    802004aa:	7442                	ld	s0,48(sp)
    802004ac:	6121                	addi	sp,sp,64
    802004ae:	8082                	ret

00000000802004b0 <console_intr>:

void
console_intr(int ch) {
    802004b0:	1101                	addi	sp,sp,-32
    802004b2:	ec06                	sd	ra,24(sp)
    802004b4:	e822                	sd	s0,16(sp)
    802004b6:	1000                	addi	s0,sp,32
    802004b8:	87aa                	mv	a5,a0
    802004ba:	fef42623          	sw	a5,-20(s0)
    spinlock_acquire(&console.lk);
    802004be:	00015517          	auipc	a0,0x15
    802004c2:	b4a50513          	addi	a0,a0,-1206 # 80215008 <console>
    802004c6:	00004097          	auipc	ra,0x4
    802004ca:	48c080e7          	jalr	1164(ra) # 80204952 <spinlock_acquire>
    console_putc(ch);
    802004ce:	fec42783          	lw	a5,-20(s0)
    802004d2:	853e                	mv	a0,a5
    802004d4:	00000097          	auipc	ra,0x0
    802004d8:	d86080e7          	jalr	-634(ra) # 8020025a <console_putc>
    if ((console.write - console.read) >= BUFSIZE) {
    802004dc:	00015797          	auipc	a5,0x15
    802004e0:	b2c78793          	addi	a5,a5,-1236 # 80215008 <console>
    802004e4:	09c7a703          	lw	a4,156(a5)
    802004e8:	00015797          	auipc	a5,0x15
    802004ec:	b2078793          	addi	a5,a5,-1248 # 80215008 <console>
    802004f0:	0987a783          	lw	a5,152(a5)
    802004f4:	40f707bb          	subw	a5,a4,a5
    802004f8:	2781                	sext.w	a5,a5
    802004fa:	873e                	mv	a4,a5
    802004fc:	07f00793          	li	a5,127
    80200500:	00e7fb63          	bgeu	a5,a4,80200516 <console_intr+0x66>
        panic("console buf full");
    80200504:	0000b517          	auipc	a0,0xb
    80200508:	b6c50513          	addi	a0,a0,-1172 # 8020b070 <etext+0x70>
    8020050c:	00002097          	auipc	ra,0x2
    80200510:	5f8080e7          	jalr	1528(ra) # 80202b04 <panic>
        while (1)
    80200514:	a001                	j	80200514 <console_intr+0x64>
            ;
    }
    console.buf[console.write % BUFSIZE] = ch;
    80200516:	00015797          	auipc	a5,0x15
    8020051a:	af278793          	addi	a5,a5,-1294 # 80215008 <console>
    8020051e:	09c7a783          	lw	a5,156(a5)
    80200522:	07f7f793          	andi	a5,a5,127
    80200526:	2781                	sext.w	a5,a5
    80200528:	fec42703          	lw	a4,-20(s0)
    8020052c:	0ff77713          	zext.b	a4,a4
    80200530:	00015697          	auipc	a3,0x15
    80200534:	ad868693          	addi	a3,a3,-1320 # 80215008 <console>
    80200538:	1782                	slli	a5,a5,0x20
    8020053a:	9381                	srli	a5,a5,0x20
    8020053c:	97b6                	add	a5,a5,a3
    8020053e:	00e78c23          	sb	a4,24(a5)
    console.write++;
    80200542:	00015797          	auipc	a5,0x15
    80200546:	ac678793          	addi	a5,a5,-1338 # 80215008 <console>
    8020054a:	09c7a783          	lw	a5,156(a5)
    8020054e:	2785                	addiw	a5,a5,1
    80200550:	0007871b          	sext.w	a4,a5
    80200554:	00015797          	auipc	a5,0x15
    80200558:	ab478793          	addi	a5,a5,-1356 # 80215008 <console>
    8020055c:	08e7ae23          	sw	a4,156(a5)
    if ((ch == '\n') || (console.write == console.read + BUFSIZE)) {
    80200560:	fec42783          	lw	a5,-20(s0)
    80200564:	0007871b          	sext.w	a4,a5
    80200568:	47a9                	li	a5,10
    8020056a:	02f70363          	beq	a4,a5,80200590 <console_intr+0xe0>
    8020056e:	00015797          	auipc	a5,0x15
    80200572:	a9a78793          	addi	a5,a5,-1382 # 80215008 <console>
    80200576:	09c7a703          	lw	a4,156(a5)
    8020057a:	00015797          	auipc	a5,0x15
    8020057e:	a8e78793          	addi	a5,a5,-1394 # 80215008 <console>
    80200582:	0987a783          	lw	a5,152(a5)
    80200586:	0807879b          	addiw	a5,a5,128
    8020058a:	2781                	sext.w	a5,a5
    8020058c:	00f71a63          	bne	a4,a5,802005a0 <console_intr+0xf0>
        proc_wakeupSpin(&console.read);  // TODO
    80200590:	00015517          	auipc	a0,0x15
    80200594:	b1050513          	addi	a0,a0,-1264 # 802150a0 <console+0x98>
    80200598:	00002097          	auipc	ra,0x2
    8020059c:	e1a080e7          	jalr	-486(ra) # 802023b2 <proc_wakeupSpin>
    }
    spinlock_release(&console.lk);
    802005a0:	00015517          	auipc	a0,0x15
    802005a4:	a6850513          	addi	a0,a0,-1432 # 80215008 <console>
    802005a8:	00004097          	auipc	ra,0x4
    802005ac:	420080e7          	jalr	1056(ra) # 802049c8 <spinlock_release>
}
    802005b0:	0001                	nop
    802005b2:	60e2                	ld	ra,24(sp)
    802005b4:	6442                	ld	s0,16(sp)
    802005b6:	6105                	addi	sp,sp,32
    802005b8:	8082                	ret

00000000802005ba <r_tp>:

static inline register_t
r_tp(void)
{
    802005ba:	1101                	addi	sp,sp,-32
    802005bc:	ec22                	sd	s0,24(sp)
    802005be:	1000                	addi	s0,sp,32
    register_t x;
    asm volatile("mv %0, tp"
    802005c0:	8792                	mv	a5,tp
    802005c2:	fef43423          	sd	a5,-24(s0)
                 : "=r"(x));
    return x;
    802005c6:	fe843783          	ld	a5,-24(s0)
}
    802005ca:	853e                	mv	a0,a5
    802005cc:	6462                	ld	s0,24(sp)
    802005ce:	6105                	addi	sp,sp,32
    802005d0:	8082                	ret

00000000802005d2 <w_satp>:
// riscv64 sv39 page table
static inline void
w_satp(address_t satp_data) {
    802005d2:	1101                	addi	sp,sp,-32
    802005d4:	ec22                	sd	s0,24(sp)
    802005d6:	1000                	addi	s0,sp,32
    802005d8:	fea43423          	sd	a0,-24(s0)
    asm volatile("csrw satp, %0"
    802005dc:	fe843783          	ld	a5,-24(s0)
    802005e0:	18079073          	csrw	satp,a5
                 :
                 : "r"(satp_data));
}
    802005e4:	0001                	nop
    802005e6:	6462                	ld	s0,24(sp)
    802005e8:	6105                	addi	sp,sp,32
    802005ea:	8082                	ret

00000000802005ec <sfenve_vma>:
static inline void
sfenve_vma() {
    802005ec:	1141                	addi	sp,sp,-16
    802005ee:	e422                	sd	s0,8(sp)
    802005f0:	0800                	addi	s0,sp,16
    asm volatile("sfence.vma");
    802005f2:	12000073          	sfence.vma
}
    802005f6:	0001                	nop
    802005f8:	6422                	ld	s0,8(sp)
    802005fa:	0141                	addi	sp,sp,16
    802005fc:	8082                	ret

00000000802005fe <kinit>:
    page* free_page_list;
    uint32_t npages;
} kmem;

void
kinit() {
    802005fe:	1141                	addi	sp,sp,-16
    80200600:	e406                	sd	ra,8(sp)
    80200602:	e022                	sd	s0,0(sp)
    80200604:	0800                	addi	s0,sp,16
    spinlock_init(&kmem.lk, "kmem");
    80200606:	0000b597          	auipc	a1,0xb
    8020060a:	a8258593          	addi	a1,a1,-1406 # 8020b088 <etext+0x88>
    8020060e:	00015517          	auipc	a0,0x15
    80200612:	a9a50513          	addi	a0,a0,-1382 # 802150a8 <kmem>
    80200616:	00004097          	auipc	ra,0x4
    8020061a:	30c080e7          	jalr	780(ra) # 80204922 <spinlock_init>
    kmem.free_page_list = NULL;
    8020061e:	00015797          	auipc	a5,0x15
    80200622:	a8a78793          	addi	a5,a5,-1398 # 802150a8 <kmem>
    80200626:	0007bc23          	sd	zero,24(a5)
    kmem.npages = 0;
    8020062a:	00015797          	auipc	a5,0x15
    8020062e:	a7e78793          	addi	a5,a5,-1410 # 802150a8 <kmem>
    80200632:	0207a023          	sw	zero,32(a5)
    kfree_pages(kernel_end, (void*)PA_STOP);
    80200636:	40300793          	li	a5,1027
    8020063a:	01579593          	slli	a1,a5,0x15
    8020063e:	00332517          	auipc	a0,0x332
    80200642:	9c250513          	addi	a0,a0,-1598 # 80532000 <kernel_end>
    80200646:	00000097          	auipc	ra,0x0
    8020064a:	012080e7          	jalr	18(ra) # 80200658 <kfree_pages>
}
    8020064e:	0001                	nop
    80200650:	60a2                	ld	ra,8(sp)
    80200652:	6402                	ld	s0,0(sp)
    80200654:	0141                	addi	sp,sp,16
    80200656:	8082                	ret

0000000080200658 <kfree_pages>:

void
kfree_pages(void* pa_start, void* pa_end) {
    80200658:	7179                	addi	sp,sp,-48
    8020065a:	f406                	sd	ra,40(sp)
    8020065c:	f022                	sd	s0,32(sp)
    8020065e:	1800                	addi	s0,sp,48
    80200660:	fca43c23          	sd	a0,-40(s0)
    80200664:	fcb43823          	sd	a1,-48(s0)
    byte_t* p = (byte_t*)pa_start;
    80200668:	fd843783          	ld	a5,-40(s0)
    8020066c:	fef43423          	sd	a5,-24(s0)
    p = (byte_t*)PAGE_ROUND_UP(p);  // PPN must be 4k aligned
    80200670:	fe843703          	ld	a4,-24(s0)
    80200674:	6785                	lui	a5,0x1
    80200676:	17fd                	addi	a5,a5,-1 # fff <_entry-0x801ff001>
    80200678:	973e                	add	a4,a4,a5
    8020067a:	77fd                	lui	a5,0xfffff
    8020067c:	8ff9                	and	a5,a5,a4
    8020067e:	fef43423          	sd	a5,-24(s0)
    for (; p < (byte_t*)pa_end; p += PAGE_SIZE) {
    80200682:	a829                	j	8020069c <kfree_pages+0x44>
        kfree(p);
    80200684:	fe843503          	ld	a0,-24(s0)
    80200688:	00000097          	auipc	ra,0x0
    8020068c:	02c080e7          	jalr	44(ra) # 802006b4 <kfree>
    for (; p < (byte_t*)pa_end; p += PAGE_SIZE) {
    80200690:	fe843703          	ld	a4,-24(s0)
    80200694:	6785                	lui	a5,0x1
    80200696:	97ba                	add	a5,a5,a4
    80200698:	fef43423          	sd	a5,-24(s0)
    8020069c:	fe843703          	ld	a4,-24(s0)
    802006a0:	fd043783          	ld	a5,-48(s0)
    802006a4:	fef760e3          	bltu	a4,a5,80200684 <kfree_pages+0x2c>
    }
}
    802006a8:	0001                	nop
    802006aa:	0001                	nop
    802006ac:	70a2                	ld	ra,40(sp)
    802006ae:	7402                	ld	s0,32(sp)
    802006b0:	6145                	addi	sp,sp,48
    802006b2:	8082                	ret

00000000802006b4 <kfree>:

void
kfree(void* pa) {
    802006b4:	7179                	addi	sp,sp,-48
    802006b6:	f406                	sd	ra,40(sp)
    802006b8:	f022                	sd	s0,32(sp)
    802006ba:	1800                	addi	s0,sp,48
    802006bc:	fca43c23          	sd	a0,-40(s0)
    page* p;
    if ((address_t)pa % PAGE_SIZE != 0 || (address_t)pa < (address_t)kernel_end || (address_t)pa >= PA_STOP) {
    802006c0:	fd843703          	ld	a4,-40(s0)
    802006c4:	6785                	lui	a5,0x1
    802006c6:	17fd                	addi	a5,a5,-1 # fff <_entry-0x801ff001>
    802006c8:	8ff9                	and	a5,a5,a4
    802006ca:	e385                	bnez	a5,802006ea <kfree+0x36>
    802006cc:	fd843703          	ld	a4,-40(s0)
    802006d0:	00332797          	auipc	a5,0x332
    802006d4:	93078793          	addi	a5,a5,-1744 # 80532000 <kernel_end>
    802006d8:	00f76963          	bltu	a4,a5,802006ea <kfree+0x36>
    802006dc:	fd843703          	ld	a4,-40(s0)
    802006e0:	40300793          	li	a5,1027
    802006e4:	07d6                	slli	a5,a5,0x15
    802006e6:	00f76a63          	bltu	a4,a5,802006fa <kfree+0x46>
        panic("kfree");
    802006ea:	0000b517          	auipc	a0,0xb
    802006ee:	9a650513          	addi	a0,a0,-1626 # 8020b090 <etext+0x90>
    802006f2:	00002097          	auipc	ra,0x2
    802006f6:	412080e7          	jalr	1042(ra) # 80202b04 <panic>
    }
    // fill with junk
    memset(pa, 1, PAGE_SIZE);
    802006fa:	6605                	lui	a2,0x1
    802006fc:	4585                	li	a1,1
    802006fe:	fd843503          	ld	a0,-40(s0)
    80200702:	00002097          	auipc	ra,0x2
    80200706:	424080e7          	jalr	1060(ra) # 80202b26 <memset>
    p = (page*)pa;
    8020070a:	fd843783          	ld	a5,-40(s0)
    8020070e:	fef43423          	sd	a5,-24(s0)
    spinlock_acquire(&kmem.lk);
    80200712:	00015517          	auipc	a0,0x15
    80200716:	99650513          	addi	a0,a0,-1642 # 802150a8 <kmem>
    8020071a:	00004097          	auipc	ra,0x4
    8020071e:	238080e7          	jalr	568(ra) # 80204952 <spinlock_acquire>
    p->next = kmem.free_page_list;
    80200722:	00015797          	auipc	a5,0x15
    80200726:	98678793          	addi	a5,a5,-1658 # 802150a8 <kmem>
    8020072a:	6f98                	ld	a4,24(a5)
    8020072c:	fe843783          	ld	a5,-24(s0)
    80200730:	e398                	sd	a4,0(a5)
    kmem.free_page_list = p;
    80200732:	00015797          	auipc	a5,0x15
    80200736:	97678793          	addi	a5,a5,-1674 # 802150a8 <kmem>
    8020073a:	fe843703          	ld	a4,-24(s0)
    8020073e:	ef98                	sd	a4,24(a5)
    ++kmem.npages;
    80200740:	00015797          	auipc	a5,0x15
    80200744:	96878793          	addi	a5,a5,-1688 # 802150a8 <kmem>
    80200748:	539c                	lw	a5,32(a5)
    8020074a:	2785                	addiw	a5,a5,1
    8020074c:	0007871b          	sext.w	a4,a5
    80200750:	00015797          	auipc	a5,0x15
    80200754:	95878793          	addi	a5,a5,-1704 # 802150a8 <kmem>
    80200758:	d398                	sw	a4,32(a5)
    spinlock_release(&kmem.lk);
    8020075a:	00015517          	auipc	a0,0x15
    8020075e:	94e50513          	addi	a0,a0,-1714 # 802150a8 <kmem>
    80200762:	00004097          	auipc	ra,0x4
    80200766:	266080e7          	jalr	614(ra) # 802049c8 <spinlock_release>
}
    8020076a:	0001                	nop
    8020076c:	70a2                	ld	ra,40(sp)
    8020076e:	7402                	ld	s0,32(sp)
    80200770:	6145                	addi	sp,sp,48
    80200772:	8082                	ret

0000000080200774 <kalloc>:

void*
kalloc(void) {
    80200774:	1101                	addi	sp,sp,-32
    80200776:	ec06                	sd	ra,24(sp)
    80200778:	e822                	sd	s0,16(sp)
    8020077a:	1000                	addi	s0,sp,32
    page* p;
    spinlock_acquire(&kmem.lk);
    8020077c:	00015517          	auipc	a0,0x15
    80200780:	92c50513          	addi	a0,a0,-1748 # 802150a8 <kmem>
    80200784:	00004097          	auipc	ra,0x4
    80200788:	1ce080e7          	jalr	462(ra) # 80204952 <spinlock_acquire>
    p = kmem.free_page_list;
    8020078c:	00015797          	auipc	a5,0x15
    80200790:	91c78793          	addi	a5,a5,-1764 # 802150a8 <kmem>
    80200794:	6f9c                	ld	a5,24(a5)
    80200796:	fef43423          	sd	a5,-24(s0)
    if (p == NULL) {
    8020079a:	fe843783          	ld	a5,-24(s0)
    8020079e:	eb91                	bnez	a5,802007b2 <kalloc+0x3e>
        panic("kalloc: Memory full!\n");
    802007a0:	0000b517          	auipc	a0,0xb
    802007a4:	8f850513          	addi	a0,a0,-1800 # 8020b098 <etext+0x98>
    802007a8:	00002097          	auipc	ra,0x2
    802007ac:	35c080e7          	jalr	860(ra) # 80202b04 <panic>
        while (1)
    802007b0:	a001                	j	802007b0 <kalloc+0x3c>
            ;
    }
    if (p) {
    802007b2:	fe843783          	ld	a5,-24(s0)
    802007b6:	c795                	beqz	a5,802007e2 <kalloc+0x6e>
        kmem.free_page_list = p->next;
    802007b8:	fe843783          	ld	a5,-24(s0)
    802007bc:	6398                	ld	a4,0(a5)
    802007be:	00015797          	auipc	a5,0x15
    802007c2:	8ea78793          	addi	a5,a5,-1814 # 802150a8 <kmem>
    802007c6:	ef98                	sd	a4,24(a5)
        --kmem.npages;
    802007c8:	00015797          	auipc	a5,0x15
    802007cc:	8e078793          	addi	a5,a5,-1824 # 802150a8 <kmem>
    802007d0:	539c                	lw	a5,32(a5)
    802007d2:	37fd                	addiw	a5,a5,-1
    802007d4:	0007871b          	sext.w	a4,a5
    802007d8:	00015797          	auipc	a5,0x15
    802007dc:	8d078793          	addi	a5,a5,-1840 # 802150a8 <kmem>
    802007e0:	d398                	sw	a4,32(a5)
    }
    spinlock_release(&kmem.lk);
    802007e2:	00015517          	auipc	a0,0x15
    802007e6:	8c650513          	addi	a0,a0,-1850 # 802150a8 <kmem>
    802007ea:	00004097          	auipc	ra,0x4
    802007ee:	1de080e7          	jalr	478(ra) # 802049c8 <spinlock_release>

    if (p) {
    802007f2:	fe843783          	ld	a5,-24(s0)
    802007f6:	cb89                	beqz	a5,80200808 <kalloc+0x94>
        memset(p, 0, PAGE_SIZE);
    802007f8:	6605                	lui	a2,0x1
    802007fa:	4581                	li	a1,0
    802007fc:	fe843503          	ld	a0,-24(s0)
    80200800:	00002097          	auipc	ra,0x2
    80200804:	326080e7          	jalr	806(ra) # 80202b26 <memset>
    }
    return (void*)p;
    80200808:	fe843783          	ld	a5,-24(s0)
}
    8020080c:	853e                	mv	a0,a5
    8020080e:	60e2                	ld	ra,24(sp)
    80200810:	6442                	ld	s0,16(sp)
    80200812:	6105                	addi	sp,sp,32
    80200814:	8082                	ret

0000000080200816 <kvminit>:

void
kvminit(void) {
    80200816:	1141                	addi	sp,sp,-16
    80200818:	e406                	sd	ra,8(sp)
    8020081a:	e022                	sd	s0,0(sp)
    8020081c:	0800                	addi	s0,sp,16
    kernel_pagetable = (pageTable_t)kalloc();
    8020081e:	00000097          	auipc	ra,0x0
    80200822:	f56080e7          	jalr	-170(ra) # 80200774 <kalloc>
    80200826:	872a                	mv	a4,a0
    80200828:	00015797          	auipc	a5,0x15
    8020082c:	8b878793          	addi	a5,a5,-1864 # 802150e0 <kernel_pagetable>
    80200830:	e398                	sd	a4,0(a5)
    memset(kernel_pagetable, 0, PAGE_SIZE);
    80200832:	00015797          	auipc	a5,0x15
    80200836:	8ae78793          	addi	a5,a5,-1874 # 802150e0 <kernel_pagetable>
    8020083a:	639c                	ld	a5,0(a5)
    8020083c:	6605                	lui	a2,0x1
    8020083e:	4581                	li	a1,0
    80200840:	853e                	mv	a0,a5
    80200842:	00002097          	auipc	ra,0x2
    80200846:	2e4080e7          	jalr	740(ra) # 80202b26 <memset>
    // can't write
    create_pages_map(kernel_pagetable, (address_t)UART_V, (address_t)UART, PAGE_SIZE, PTE_R | PTE_W);
    8020084a:	00015797          	auipc	a5,0x15
    8020084e:	89678793          	addi	a5,a5,-1898 # 802150e0 <kernel_pagetable>
    80200852:	6388                	ld	a0,0(a5)
    80200854:	4719                	li	a4,6
    80200856:	6685                	lui	a3,0x1
    80200858:	10000637          	lui	a2,0x10000
    8020085c:	3f100793          	li	a5,1009
    80200860:	01c79593          	slli	a1,a5,0x1c
    80200864:	00000097          	auipc	ra,0x0
    80200868:	134080e7          	jalr	308(ra) # 80200998 <create_pages_map>
    create_pages_map(kernel_pagetable, (address_t)CLINT_V, (address_t)CLINT, 0x10000, PTE_R | PTE_W);
    8020086c:	00015797          	auipc	a5,0x15
    80200870:	87478793          	addi	a5,a5,-1932 # 802150e0 <kernel_pagetable>
    80200874:	6388                	ld	a0,0(a5)
    80200876:	4719                	li	a4,6
    80200878:	66c1                	lui	a3,0x10
    8020087a:	02000637          	lui	a2,0x2000
    8020087e:	01f817b7          	lui	a5,0x1f81
    80200882:	00d79593          	slli	a1,a5,0xd
    80200886:	00000097          	auipc	ra,0x0
    8020088a:	112080e7          	jalr	274(ra) # 80200998 <create_pages_map>
    create_pages_map(kernel_pagetable, (address_t)PLIC_V, (address_t)PLIC, 0x4000, PTE_R | PTE_W);
    8020088e:	00015797          	auipc	a5,0x15
    80200892:	85278793          	addi	a5,a5,-1966 # 802150e0 <kernel_pagetable>
    80200896:	6388                	ld	a0,0(a5)
    80200898:	4719                	li	a4,6
    8020089a:	6691                	lui	a3,0x4
    8020089c:	0c000637          	lui	a2,0xc000
    802008a0:	00fc37b7          	lui	a5,0xfc3
    802008a4:	00e79593          	slli	a1,a5,0xe
    802008a8:	00000097          	auipc	ra,0x0
    802008ac:	0f0080e7          	jalr	240(ra) # 80200998 <create_pages_map>
    create_pages_map(kernel_pagetable, (address_t)PLIC_V + 0x200000, (address_t)PLIC + 0x200000, 0x4000, PTE_R | PTE_W);
    802008b0:	00015797          	auipc	a5,0x15
    802008b4:	83078793          	addi	a5,a5,-2000 # 802150e0 <kernel_pagetable>
    802008b8:	6388                	ld	a0,0(a5)
    802008ba:	4719                	li	a4,6
    802008bc:	6691                	lui	a3,0x4
    802008be:	0c200637          	lui	a2,0xc200
    802008c2:	1f8617b7          	lui	a5,0x1f861
    802008c6:	00979593          	slli	a1,a5,0x9
    802008ca:	00000097          	auipc	ra,0x0
    802008ce:	0ce080e7          	jalr	206(ra) # 80200998 <create_pages_map>
#ifdef QEMU
    create_pages_map(kernel_pagetable, (address_t)VIRTIO0_V, (address_t)VIRTIO0, PAGE_SIZE, PTE_R | PTE_W);
    802008d2:	00015797          	auipc	a5,0x15
    802008d6:	80e78793          	addi	a5,a5,-2034 # 802150e0 <kernel_pagetable>
    802008da:	6388                	ld	a0,0(a5)
    802008dc:	4719                	li	a4,6
    802008de:	6685                	lui	a3,0x1
    802008e0:	10001637          	lui	a2,0x10001
    802008e4:	03f107b7          	lui	a5,0x3f10
    802008e8:	0785                	addi	a5,a5,1 # 3f10001 <_entry-0x7c2effff>
    802008ea:	00c79593          	slli	a1,a5,0xc
    802008ee:	00000097          	auipc	ra,0x0
    802008f2:	0aa080e7          	jalr	170(ra) # 80200998 <create_pages_map>
    create_pages_map(kernel_pagetable, (address_t)SPI1_V, (address_t)SPI1, 0x1000, PTE_R | PTE_W);
    create_pages_map(kernel_pagetable, (address_t)SPI2_V, (address_t)SPI2, 0x1000, PTE_R | PTE_W);
    create_pages_map(kernel_pagetable, (address_t)SYSCTL_V, (address_t)SYSCTL, 0x1000, PTE_R | PTE_W);
#endif

    create_pages_map(kernel_pagetable, (address_t)KERNEL_START, (address_t)KERNEL_START, (uint64_t)etext - (uint64_t)KERNEL_START,
    802008f6:	00014797          	auipc	a5,0x14
    802008fa:	7ea78793          	addi	a5,a5,2026 # 802150e0 <kernel_pagetable>
    802008fe:	6388                	ld	a0,0(a5)
    80200900:	0000a717          	auipc	a4,0xa
    80200904:	70070713          	addi	a4,a4,1792 # 8020b000 <etext>
    80200908:	bff00793          	li	a5,-1025
    8020090c:	07d6                	slli	a5,a5,0x15
    8020090e:	97ba                	add	a5,a5,a4
    80200910:	4729                	li	a4,10
    80200912:	86be                	mv	a3,a5
    80200914:	40100793          	li	a5,1025
    80200918:	01579613          	slli	a2,a5,0x15
    8020091c:	40100793          	li	a5,1025
    80200920:	01579593          	slli	a1,a5,0x15
    80200924:	00000097          	auipc	ra,0x0
    80200928:	074080e7          	jalr	116(ra) # 80200998 <create_pages_map>
                     (uint64_t)(PTE_R | PTE_X));
    create_pages_map(kernel_pagetable, (address_t)etext, (address_t)etext, (uint64_t)PA_STOP - (uint64_t)etext, (uint64_t)(PTE_R | PTE_W));
    8020092c:	00014797          	auipc	a5,0x14
    80200930:	7b478793          	addi	a5,a5,1972 # 802150e0 <kernel_pagetable>
    80200934:	6388                	ld	a0,0(a5)
    80200936:	0000a597          	auipc	a1,0xa
    8020093a:	6ca58593          	addi	a1,a1,1738 # 8020b000 <etext>
    8020093e:	0000a617          	auipc	a2,0xa
    80200942:	6c260613          	addi	a2,a2,1730 # 8020b000 <etext>
    80200946:	0000a797          	auipc	a5,0xa
    8020094a:	6ba78793          	addi	a5,a5,1722 # 8020b000 <etext>
    8020094e:	40300713          	li	a4,1027
    80200952:	0756                	slli	a4,a4,0x15
    80200954:	40f707b3          	sub	a5,a4,a5
    80200958:	4719                	li	a4,6
    8020095a:	86be                	mv	a3,a5
    8020095c:	00000097          	auipc	ra,0x0
    80200960:	03c080e7          	jalr	60(ra) # 80200998 <create_pages_map>
    create_pages_map(kernel_pagetable, (address_t)TRAMPOLINE, (address_t)trampoline, PAGE_SIZE, (uint64_t)(PTE_R | PTE_X));
    80200964:	00014797          	auipc	a5,0x14
    80200968:	77c78793          	addi	a5,a5,1916 # 802150e0 <kernel_pagetable>
    8020096c:	6388                	ld	a0,0(a5)
    8020096e:	00009797          	auipc	a5,0x9
    80200972:	69278793          	addi	a5,a5,1682 # 8020a000 <_trampoline>
    80200976:	4729                	li	a4,10
    80200978:	6685                	lui	a3,0x1
    8020097a:	863e                	mv	a2,a5
    8020097c:	040007b7          	lui	a5,0x4000
    80200980:	17fd                	addi	a5,a5,-1 # 3ffffff <_entry-0x7c200001>
    80200982:	00c79593          	slli	a1,a5,0xc
    80200986:	00000097          	auipc	ra,0x0
    8020098a:	012080e7          	jalr	18(ra) # 80200998 <create_pages_map>
    // don't creat some i/o vmmap 2022/4/29
}
    8020098e:	0001                	nop
    80200990:	60a2                	ld	ra,8(sp)
    80200992:	6402                	ld	s0,0(sp)
    80200994:	0141                	addi	sp,sp,16
    80200996:	8082                	ret

0000000080200998 <create_pages_map>:
// {
//     return create_pages_map(kernel_pagetable, va, pa, size, flag);
// }

void
create_pages_map(pageTable_t pageTable, address_t va, address_t pa, uint64_t size, uint64_t flag) {
    80200998:	711d                	addi	sp,sp,-96
    8020099a:	ec86                	sd	ra,88(sp)
    8020099c:	e8a2                	sd	s0,80(sp)
    8020099e:	1080                	addi	s0,sp,96
    802009a0:	fca43423          	sd	a0,-56(s0)
    802009a4:	fcb43023          	sd	a1,-64(s0)
    802009a8:	fac43c23          	sd	a2,-72(s0)
    802009ac:	fad43823          	sd	a3,-80(s0)
    802009b0:	fae43423          	sd	a4,-88(s0)
    address_t a, last;
    pte_t* pte;
    a = PAGE_ROUND_DOWN(va);
    802009b4:	fc043703          	ld	a4,-64(s0)
    802009b8:	77fd                	lui	a5,0xfffff
    802009ba:	8ff9                	and	a5,a5,a4
    802009bc:	fef43423          	sd	a5,-24(s0)
    last = PAGE_ROUND_DOWN(va + size - 1);
    802009c0:	fc043703          	ld	a4,-64(s0)
    802009c4:	fb043783          	ld	a5,-80(s0)
    802009c8:	97ba                	add	a5,a5,a4
    802009ca:	fff78713          	addi	a4,a5,-1 # ffffffffffffefff <kernel_end+0xffffffff7faccfff>
    802009ce:	77fd                	lui	a5,0xfffff
    802009d0:	8ff9                	and	a5,a5,a4
    802009d2:	fef43023          	sd	a5,-32(s0)
    while (1) {
        pte = get_level0_pte(pageTable, a, 1);
    802009d6:	4605                	li	a2,1
    802009d8:	fe843583          	ld	a1,-24(s0)
    802009dc:	fc843503          	ld	a0,-56(s0)
    802009e0:	00000097          	auipc	ra,0x0
    802009e4:	088080e7          	jalr	136(ra) # 80200a68 <get_level0_pte>
    802009e8:	fca43c23          	sd	a0,-40(s0)
        if (!pte) {
    802009ec:	fd843783          	ld	a5,-40(s0)
    802009f0:	eb89                	bnez	a5,80200a02 <create_pages_map+0x6a>
            panic("full");
    802009f2:	0000a517          	auipc	a0,0xa
    802009f6:	6be50513          	addi	a0,a0,1726 # 8020b0b0 <etext+0xb0>
    802009fa:	00002097          	auipc	ra,0x2
    802009fe:	10a080e7          	jalr	266(ra) # 80202b04 <panic>
        }
        if ((*pte & PTE_V) == 1) {
    80200a02:	fd843783          	ld	a5,-40(s0)
    80200a06:	639c                	ld	a5,0(a5)
    80200a08:	8b85                	andi	a5,a5,1
    80200a0a:	cb89                	beqz	a5,80200a1c <create_pages_map+0x84>
            panic("kvmmap-remap");
    80200a0c:	0000a517          	auipc	a0,0xa
    80200a10:	6ac50513          	addi	a0,a0,1708 # 8020b0b8 <etext+0xb8>
    80200a14:	00002097          	auipc	ra,0x2
    80200a18:	0f0080e7          	jalr	240(ra) # 80202b04 <panic>
        }
        *pte = GET_PPN(pa) | flag | PTE_V;
    80200a1c:	fb843783          	ld	a5,-72(s0)
    80200a20:	83b1                	srli	a5,a5,0xc
    80200a22:	00a79713          	slli	a4,a5,0xa
    80200a26:	fa843783          	ld	a5,-88(s0)
    80200a2a:	8fd9                	or	a5,a5,a4
    80200a2c:	0017e713          	ori	a4,a5,1
    80200a30:	fd843783          	ld	a5,-40(s0)
    80200a34:	e398                	sd	a4,0(a5)
        if (a == last)
    80200a36:	fe843703          	ld	a4,-24(s0)
    80200a3a:	fe043783          	ld	a5,-32(s0)
    80200a3e:	00f70f63          	beq	a4,a5,80200a5c <create_pages_map+0xc4>
            break;
        a += PAGE_SIZE;
    80200a42:	fe843703          	ld	a4,-24(s0)
    80200a46:	6785                	lui	a5,0x1
    80200a48:	97ba                	add	a5,a5,a4
    80200a4a:	fef43423          	sd	a5,-24(s0)
        pa += PAGE_SIZE;
    80200a4e:	fb843703          	ld	a4,-72(s0)
    80200a52:	6785                	lui	a5,0x1
    80200a54:	97ba                	add	a5,a5,a4
    80200a56:	faf43c23          	sd	a5,-72(s0)
        pte = get_level0_pte(pageTable, a, 1);
    80200a5a:	bfb5                	j	802009d6 <create_pages_map+0x3e>
            break;
    80200a5c:	0001                	nop
    }
    return;
    80200a5e:	0001                	nop
}
    80200a60:	60e6                	ld	ra,88(sp)
    80200a62:	6446                	ld	s0,80(sp)
    80200a64:	6125                	addi	sp,sp,96
    80200a66:	8082                	ret

0000000080200a68 <get_level0_pte>:

pte_t*
get_level0_pte(pageTable_t pageTable, address_t va, int alloc) {
    80200a68:	7139                	addi	sp,sp,-64
    80200a6a:	fc06                	sd	ra,56(sp)
    80200a6c:	f822                	sd	s0,48(sp)
    80200a6e:	0080                	addi	s0,sp,64
    80200a70:	fca43c23          	sd	a0,-40(s0)
    80200a74:	fcb43823          	sd	a1,-48(s0)
    80200a78:	87b2                	mv	a5,a2
    80200a7a:	fcf42623          	sw	a5,-52(s0)
    if (va > MAX_VA) {
    80200a7e:	fd043703          	ld	a4,-48(s0)
    80200a82:	4785                	li	a5,1
    80200a84:	179a                	slli	a5,a5,0x26
    80200a86:	00e7fa63          	bgeu	a5,a4,80200a9a <get_level0_pte+0x32>
        panic("get_level0_pte out of bound");
    80200a8a:	0000a517          	auipc	a0,0xa
    80200a8e:	63e50513          	addi	a0,a0,1598 # 8020b0c8 <etext+0xc8>
    80200a92:	00002097          	auipc	ra,0x2
    80200a96:	072080e7          	jalr	114(ra) # 80202b04 <panic>
    }
    pte_t* pte;
    for (int level = 2; level > 0; level--) {
    80200a9a:	4789                	li	a5,2
    80200a9c:	fef42623          	sw	a5,-20(s0)
    80200aa0:	a859                	j	80200b36 <get_level0_pte+0xce>
        pte = &pageTable[VPN(va, level)];  // level > 0 is right.Don't change
    80200aa2:	fec42703          	lw	a4,-20(s0)
    80200aa6:	87ba                	mv	a5,a4
    80200aa8:	0037979b          	slliw	a5,a5,0x3
    80200aac:	9fb9                	addw	a5,a5,a4
    80200aae:	2781                	sext.w	a5,a5
    80200ab0:	27b1                	addiw	a5,a5,12 # 100c <_entry-0x801feff4>
    80200ab2:	2781                	sext.w	a5,a5
    80200ab4:	873e                	mv	a4,a5
    80200ab6:	fd043783          	ld	a5,-48(s0)
    80200aba:	00e7d7b3          	srl	a5,a5,a4
    80200abe:	1ff7f793          	andi	a5,a5,511
    80200ac2:	078e                	slli	a5,a5,0x3
    80200ac4:	fd843703          	ld	a4,-40(s0)
    80200ac8:	97ba                	add	a5,a5,a4
    80200aca:	fef43023          	sd	a5,-32(s0)
        if (*pte & PTE_V) {
    80200ace:	fe043783          	ld	a5,-32(s0)
    80200ad2:	639c                	ld	a5,0(a5)
    80200ad4:	8b85                	andi	a5,a5,1
    80200ad6:	cb89                	beqz	a5,80200ae8 <get_level0_pte+0x80>
            pageTable = (pageTable_t)GET_PAGETABLE(*pte);
    80200ad8:	fe043783          	ld	a5,-32(s0)
    80200adc:	639c                	ld	a5,0(a5)
    80200ade:	83a9                	srli	a5,a5,0xa
    80200ae0:	07b2                	slli	a5,a5,0xc
    80200ae2:	fcf43c23          	sd	a5,-40(s0)
    80200ae6:	a099                	j	80200b2c <get_level0_pte+0xc4>
        } else {
            if (!alloc)
    80200ae8:	fcc42783          	lw	a5,-52(s0)
    80200aec:	2781                	sext.w	a5,a5
    80200aee:	e399                	bnez	a5,80200af4 <get_level0_pte+0x8c>
                return NULL;
    80200af0:	4781                	li	a5,0
    80200af2:	a085                	j	80200b52 <get_level0_pte+0xea>
            pageTable = (pageTable_t)kalloc();
    80200af4:	00000097          	auipc	ra,0x0
    80200af8:	c80080e7          	jalr	-896(ra) # 80200774 <kalloc>
    80200afc:	fca43c23          	sd	a0,-40(s0)
            if (pageTable == NULL)
    80200b00:	fd843783          	ld	a5,-40(s0)
    80200b04:	e399                	bnez	a5,80200b0a <get_level0_pte+0xa2>
                return NULL;
    80200b06:	4781                	li	a5,0
    80200b08:	a0a9                	j	80200b52 <get_level0_pte+0xea>
            memset(pageTable, 0, PAGE_SIZE);
    80200b0a:	6605                	lui	a2,0x1
    80200b0c:	4581                	li	a1,0
    80200b0e:	fd843503          	ld	a0,-40(s0)
    80200b12:	00002097          	auipc	ra,0x2
    80200b16:	014080e7          	jalr	20(ra) # 80202b26 <memset>
            *pte = GET_PPN(pageTable) | PTE_V;
    80200b1a:	fd843783          	ld	a5,-40(s0)
    80200b1e:	83b1                	srli	a5,a5,0xc
    80200b20:	07aa                	slli	a5,a5,0xa
    80200b22:	0017e713          	ori	a4,a5,1
    80200b26:	fe043783          	ld	a5,-32(s0)
    80200b2a:	e398                	sd	a4,0(a5)
    for (int level = 2; level > 0; level--) {
    80200b2c:	fec42783          	lw	a5,-20(s0)
    80200b30:	37fd                	addiw	a5,a5,-1
    80200b32:	fef42623          	sw	a5,-20(s0)
    80200b36:	fec42783          	lw	a5,-20(s0)
    80200b3a:	2781                	sext.w	a5,a5
    80200b3c:	f6f043e3          	bgtz	a5,80200aa2 <get_level0_pte+0x3a>
        }
    }
    // debug

    // pageTable_t x = &pageTable[VPN(va, 0)];
    return &pageTable[VPN(va, 0)];
    80200b40:	fd043783          	ld	a5,-48(s0)
    80200b44:	83b1                	srli	a5,a5,0xc
    80200b46:	1ff7f793          	andi	a5,a5,511
    80200b4a:	078e                	slli	a5,a5,0x3
    80200b4c:	fd843703          	ld	a4,-40(s0)
    80200b50:	97ba                	add	a5,a5,a4
}
    80200b52:	853e                	mv	a0,a5
    80200b54:	70e2                	ld	ra,56(sp)
    80200b56:	7442                	ld	s0,48(sp)
    80200b58:	6121                	addi	sp,sp,64
    80200b5a:	8082                	ret

0000000080200b5c <kvminithart>:

void
kvminithart() {
    80200b5c:	1141                	addi	sp,sp,-16
    80200b5e:	e406                	sd	ra,8(sp)
    80200b60:	e022                	sd	s0,0(sp)
    80200b62:	0800                	addi	s0,sp,16
    w_satp(PAGE_TABLE_SHIFT(kernel_pagetable));
    80200b64:	00014797          	auipc	a5,0x14
    80200b68:	57c78793          	addi	a5,a5,1404 # 802150e0 <kernel_pagetable>
    80200b6c:	639c                	ld	a5,0(a5)
    80200b6e:	00c7d713          	srli	a4,a5,0xc
    80200b72:	57fd                	li	a5,-1
    80200b74:	17fe                	slli	a5,a5,0x3f
    80200b76:	8fd9                	or	a5,a5,a4
    80200b78:	853e                	mv	a0,a5
    80200b7a:	00000097          	auipc	ra,0x0
    80200b7e:	a58080e7          	jalr	-1448(ra) # 802005d2 <w_satp>
    sfenve_vma();
    80200b82:	00000097          	auipc	ra,0x0
    80200b86:	a6a080e7          	jalr	-1430(ra) # 802005ec <sfenve_vma>
}
    80200b8a:	0001                	nop
    80200b8c:	60a2                	ld	ra,8(sp)
    80200b8e:	6402                	ld	s0,0(sp)
    80200b90:	0141                	addi	sp,sp,16
    80200b92:	8082                	ret

0000000080200b94 <kvm_trans>:
//          return NULL;
//      pa = GET_PA(va, *pte)
//      return pa;
//  }
address_t
kvm_trans(address_t va, pageTable_t pagetable) {
    80200b94:	7179                	addi	sp,sp,-48
    80200b96:	f406                	sd	ra,40(sp)
    80200b98:	f022                	sd	s0,32(sp)
    80200b9a:	1800                	addi	s0,sp,48
    80200b9c:	fca43c23          	sd	a0,-40(s0)
    80200ba0:	fcb43823          	sd	a1,-48(s0)
    uint64_t pa;
    pte_t* pte = get_level0_pte(pagetable, va, 0);
    80200ba4:	4601                	li	a2,0
    80200ba6:	fd843583          	ld	a1,-40(s0)
    80200baa:	fd043503          	ld	a0,-48(s0)
    80200bae:	00000097          	auipc	ra,0x0
    80200bb2:	eba080e7          	jalr	-326(ra) # 80200a68 <get_level0_pte>
    80200bb6:	fea43423          	sd	a0,-24(s0)
    if (pte == NULL) {
    80200bba:	fe843783          	ld	a5,-24(s0)
    80200bbe:	ef81                	bnez	a5,80200bd6 <kvm_trans+0x42>
        printf("kvm_trans: unmapped va: %p", va);
    80200bc0:	fd843583          	ld	a1,-40(s0)
    80200bc4:	0000a517          	auipc	a0,0xa
    80200bc8:	52450513          	addi	a0,a0,1316 # 8020b0e8 <etext+0xe8>
    80200bcc:	00002097          	auipc	ra,0x2
    80200bd0:	d26080e7          	jalr	-730(ra) # 802028f2 <printf>
        while (1)
    80200bd4:	a001                	j	80200bd4 <kvm_trans+0x40>
            ;
    }
    if ((*pte & PTE_V) == 0) {
    80200bd6:	fe843783          	ld	a5,-24(s0)
    80200bda:	639c                	ld	a5,0(a5)
    80200bdc:	8b85                	andi	a5,a5,1
    80200bde:	ef81                	bnez	a5,80200bf6 <kvm_trans+0x62>
        printf("kvm_trans: unmapped va: %p", va);
    80200be0:	fd843583          	ld	a1,-40(s0)
    80200be4:	0000a517          	auipc	a0,0xa
    80200be8:	50450513          	addi	a0,a0,1284 # 8020b0e8 <etext+0xe8>
    80200bec:	00002097          	auipc	ra,0x2
    80200bf0:	d06080e7          	jalr	-762(ra) # 802028f2 <printf>
        while (1)
    80200bf4:	a001                	j	80200bf4 <kvm_trans+0x60>
            ;
    }
    pa = GET_PA(va, *pte);
    80200bf6:	fd843703          	ld	a4,-40(s0)
    80200bfa:	6785                	lui	a5,0x1
    80200bfc:	17fd                	addi	a5,a5,-1 # fff <_entry-0x801ff001>
    80200bfe:	8f7d                	and	a4,a4,a5
    80200c00:	fe843783          	ld	a5,-24(s0)
    80200c04:	639c                	ld	a5,0(a5)
    80200c06:	83a9                	srli	a5,a5,0xa
    80200c08:	07b2                	slli	a5,a5,0xc
    80200c0a:	97ba                	add	a5,a5,a4
    80200c0c:	fef43023          	sd	a5,-32(s0)
    return pa;
    80200c10:	fe043783          	ld	a5,-32(s0)
}
    80200c14:	853e                	mv	a0,a5
    80200c16:	70a2                	ld	ra,40(sp)
    80200c18:	7402                	ld	s0,32(sp)
    80200c1a:	6145                	addi	sp,sp,48
    80200c1c:	8082                	ret

0000000080200c1e <kmm_init>:
void
kmm_init(void) {
    80200c1e:	1141                	addi	sp,sp,-16
    80200c20:	e406                	sd	ra,8(sp)
    80200c22:	e022                	sd	s0,0(sp)
    80200c24:	0800                	addi	s0,sp,16
#ifdef DEBUG
    // printf("hartid: %d      function: kmm_init", r_tp());
    printf("hartid: %d      function: kmm_init", r_tp());  // mayneed lock
    80200c26:	00000097          	auipc	ra,0x0
    80200c2a:	994080e7          	jalr	-1644(ra) # 802005ba <r_tp>
    80200c2e:	87aa                	mv	a5,a0
    80200c30:	85be                	mv	a1,a5
    80200c32:	0000a517          	auipc	a0,0xa
    80200c36:	4d650513          	addi	a0,a0,1238 # 8020b108 <etext+0x108>
    80200c3a:	00002097          	auipc	ra,0x2
    80200c3e:	cb8080e7          	jalr	-840(ra) # 802028f2 <printf>
#endif
    listp = 0;
    80200c42:	00014797          	auipc	a5,0x14
    80200c46:	49678793          	addi	a5,a5,1174 # 802150d8 <listp>
    80200c4a:	0007b023          	sd	zero,0(a5)
    extend_heap();
    80200c4e:	00000097          	auipc	ra,0x0
    80200c52:	45a080e7          	jalr	1114(ra) # 802010a8 <extend_heap>
    return;
    80200c56:	0001                	nop
}
    80200c58:	60a2                	ld	ra,8(sp)
    80200c5a:	6402                	ld	s0,0(sp)
    80200c5c:	0141                	addi	sp,sp,16
    80200c5e:	8082                	ret

0000000080200c60 <kmalloc>:

void*
kmalloc(uint64_t size) {
    80200c60:	7179                	addi	sp,sp,-48
    80200c62:	f406                	sd	ra,40(sp)
    80200c64:	f022                	sd	s0,32(sp)
    80200c66:	1800                	addi	s0,sp,48
    80200c68:	fca43c23          	sd	a0,-40(s0)
    uint64_t newsize = ALIGN(size);
    80200c6c:	fd843783          	ld	a5,-40(s0)
    80200c70:	07fd                	addi	a5,a5,31
    80200c72:	9be1                	andi	a5,a5,-8
    80200c74:	fef43023          	sd	a5,-32(s0)
    void* goal;
    goal = find_first_fit(newsize);
    80200c78:	fe043503          	ld	a0,-32(s0)
    80200c7c:	00000097          	auipc	ra,0x0
    80200c80:	55e080e7          	jalr	1374(ra) # 802011da <find_first_fit>
    80200c84:	fea43423          	sd	a0,-24(s0)
    if (goal == 0) {
    80200c88:	fe843783          	ld	a5,-24(s0)
    80200c8c:	e799                	bnez	a5,80200c9a <kmalloc+0x3a>
        goal = extend_heap();
    80200c8e:	00000097          	auipc	ra,0x0
    80200c92:	41a080e7          	jalr	1050(ra) # 802010a8 <extend_heap>
    80200c96:	fea43423          	sd	a0,-24(s0)
    }
    place(goal, newsize);
    80200c9a:	fe043583          	ld	a1,-32(s0)
    80200c9e:	fe843503          	ld	a0,-24(s0)
    80200ca2:	00000097          	auipc	ra,0x0
    80200ca6:	464080e7          	jalr	1124(ra) # 80201106 <place>
    return goal;
    80200caa:	fe843783          	ld	a5,-24(s0)
}
    80200cae:	853e                	mv	a0,a5
    80200cb0:	70a2                	ld	ra,40(sp)
    80200cb2:	7402                	ld	s0,32(sp)
    80200cb4:	6145                	addi	sp,sp,48
    80200cb6:	8082                	ret

0000000080200cb8 <kmfree>:

void
kmfree(void* address) {
    80200cb8:	7179                	addi	sp,sp,-48
    80200cba:	f406                	sd	ra,40(sp)
    80200cbc:	f022                	sd	s0,32(sp)
    80200cbe:	1800                	addi	s0,sp,48
    80200cc0:	fca43c23          	sd	a0,-40(s0)
    PUT(HEAD(address), PACK(GET_SIZE(address), 0));
    80200cc4:	fd843783          	ld	a5,-40(s0)
    80200cc8:	17a1                	addi	a5,a5,-24
    80200cca:	6398                	ld	a4,0(a5)
    80200ccc:	fd843783          	ld	a5,-40(s0)
    80200cd0:	17a1                	addi	a5,a5,-24
    80200cd2:	9b61                	andi	a4,a4,-8
    80200cd4:	e398                	sd	a4,0(a5)
    void* free_page = merge(address);
    80200cd6:	fd843503          	ld	a0,-40(s0)
    80200cda:	00000097          	auipc	ra,0x0
    80200cde:	072080e7          	jalr	114(ra) # 80200d4c <merge>
    80200ce2:	fea43423          	sd	a0,-24(s0)
    ;
    if ((GET_SIZE(free_page) >= PAGE_SIZE) && (((uint64_t)free_page & (uint64_t)4095) == 0)) {
    80200ce6:	fe843783          	ld	a5,-24(s0)
    80200cea:	17a1                	addi	a5,a5,-24
    80200cec:	639c                	ld	a5,0(a5)
    80200cee:	ff87f713          	andi	a4,a5,-8
    80200cf2:	6785                	lui	a5,0x1
    80200cf4:	04f76763          	bltu	a4,a5,80200d42 <kmfree+0x8a>
    80200cf8:	fe843703          	ld	a4,-24(s0)
    80200cfc:	6785                	lui	a5,0x1
    80200cfe:	17fd                	addi	a5,a5,-1 # fff <_entry-0x801ff001>
    80200d00:	8ff9                	and	a5,a5,a4
    80200d02:	e3a1                	bnez	a5,80200d42 <kmfree+0x8a>
        // TODO 变量未使用 pte_t* pte = get_level0_pte(kernel_pagetable, (address_t)free_page, 0);
        kfree(free_page);
    80200d04:	fe843503          	ld	a0,-24(s0)
    80200d08:	00000097          	auipc	ra,0x0
    80200d0c:	9ac080e7          	jalr	-1620(ra) # 802006b4 <kfree>
#ifdef DEBUG
        printf("kmfree: free page\n");
    80200d10:	0000a517          	auipc	a0,0xa
    80200d14:	42050513          	addi	a0,a0,1056 # 8020b130 <etext+0x130>
    80200d18:	00002097          	auipc	ra,0x2
    80200d1c:	bda080e7          	jalr	-1062(ra) # 802028f2 <printf>
        printf("address: %p,  size: %d", free_page, GET_SIZE(free_page));
    80200d20:	fe843783          	ld	a5,-24(s0)
    80200d24:	17a1                	addi	a5,a5,-24
    80200d26:	639c                	ld	a5,0(a5)
    80200d28:	9be1                	andi	a5,a5,-8
    80200d2a:	863e                	mv	a2,a5
    80200d2c:	fe843583          	ld	a1,-24(s0)
    80200d30:	0000a517          	auipc	a0,0xa
    80200d34:	41850513          	addi	a0,a0,1048 # 8020b148 <etext+0x148>
    80200d38:	00002097          	auipc	ra,0x2
    80200d3c:	bba080e7          	jalr	-1094(ra) # 802028f2 <printf>
#endif
    }
    return;
    80200d40:	0001                	nop
    80200d42:	0001                	nop
}
    80200d44:	70a2                	ld	ra,40(sp)
    80200d46:	7402                	ld	s0,32(sp)
    80200d48:	6145                	addi	sp,sp,48
    80200d4a:	8082                	ret

0000000080200d4c <merge>:

void*
merge(void* address) {
    80200d4c:	715d                	addi	sp,sp,-80
    80200d4e:	e4a2                	sd	s0,72(sp)
    80200d50:	0880                	addi	s0,sp,80
    80200d52:	faa43c23          	sd	a0,-72(s0)
    byte_t* prev = (byte_t*)PREV_ADDRESS(address);
    80200d56:	fb843783          	ld	a5,-72(s0)
    80200d5a:	17c1                	addi	a5,a5,-16
    80200d5c:	639c                	ld	a5,0(a5)
    80200d5e:	fef43423          	sd	a5,-24(s0)
    byte_t* next = (byte_t*)NEXT_ADDRESS(address);
    80200d62:	fb843783          	ld	a5,-72(s0)
    80200d66:	17e1                	addi	a5,a5,-8
    80200d68:	639c                	ld	a5,0(a5)
    80200d6a:	fef43023          	sd	a5,-32(s0)
    uint64_t size = GET_SIZE(address);
    80200d6e:	fb843783          	ld	a5,-72(s0)
    80200d72:	17a1                	addi	a5,a5,-24
    80200d74:	639c                	ld	a5,0(a5)
    80200d76:	9be1                	andi	a5,a5,-8
    80200d78:	fcf43c23          	sd	a5,-40(s0)
    uint64_t next_alloc, prev_alloc;
    if ((prev == 0) && (next == 0)) {
    80200d7c:	fe843783          	ld	a5,-24(s0)
    80200d80:	e789                	bnez	a5,80200d8a <merge+0x3e>
    80200d82:	fe043783          	ld	a5,-32(s0)
    80200d86:	30078b63          	beqz	a5,8020109c <merge+0x350>
    } else if ((prev == 0) && (next != 0)) {
    80200d8a:	fe843783          	ld	a5,-24(s0)
    80200d8e:	ebb5                	bnez	a5,80200e02 <merge+0xb6>
    80200d90:	fe043783          	ld	a5,-32(s0)
    80200d94:	c7bd                	beqz	a5,80200e02 <merge+0xb6>
        next_alloc = NEXT_ALLOC(address);
    80200d96:	fb843783          	ld	a5,-72(s0)
    80200d9a:	17e1                	addi	a5,a5,-8
    80200d9c:	639c                	ld	a5,0(a5)
    80200d9e:	17a1                	addi	a5,a5,-24
    80200da0:	639c                	ld	a5,0(a5)
    80200da2:	8b85                	andi	a5,a5,1
    80200da4:	fcf43823          	sd	a5,-48(s0)
        if (next_alloc == 0) {
    80200da8:	fd043783          	ld	a5,-48(s0)
    80200dac:	eba1                	bnez	a5,80200dfc <merge+0xb0>
            if (((uint64_t)next & (~4095)) == ((uint64_t)address & (~4095))) {
    80200dae:	fe043703          	ld	a4,-32(s0)
    80200db2:	fb843783          	ld	a5,-72(s0)
    80200db6:	8f3d                	xor	a4,a4,a5
    80200db8:	77fd                	lui	a5,0xfffff
    80200dba:	8ff9                	and	a5,a5,a4
    80200dbc:	e3a1                	bnez	a5,80200dfc <merge+0xb0>
                size += GET_SIZE(next);
    80200dbe:	fe043783          	ld	a5,-32(s0)
    80200dc2:	17a1                	addi	a5,a5,-24 # ffffffffffffefe8 <kernel_end+0xffffffff7faccfe8>
    80200dc4:	639c                	ld	a5,0(a5)
    80200dc6:	9be1                	andi	a5,a5,-8
    80200dc8:	fd843703          	ld	a4,-40(s0)
    80200dcc:	97ba                	add	a5,a5,a4
    80200dce:	fcf43c23          	sd	a5,-40(s0)
                PUT(HEAD(address), PACK(size, 0));
    80200dd2:	fb843783          	ld	a5,-72(s0)
    80200dd6:	17a1                	addi	a5,a5,-24
    80200dd8:	fd843703          	ld	a4,-40(s0)
    80200ddc:	9b61                	andi	a4,a4,-8
    80200dde:	e398                	sd	a4,0(a5)
                if (NEXT_ADDRESS(next) != 0) {
    80200de0:	fe043783          	ld	a5,-32(s0)
    80200de4:	17e1                	addi	a5,a5,-8
    80200de6:	639c                	ld	a5,0(a5)
    80200de8:	cb91                	beqz	a5,80200dfc <merge+0xb0>
                    PUT(PREV(NEXT_ADDRESS((void*)next)), address);
    80200dea:	fe043783          	ld	a5,-32(s0)
    80200dee:	17e1                	addi	a5,a5,-8
    80200df0:	639c                	ld	a5,0(a5)
    80200df2:	17c1                	addi	a5,a5,-16
    80200df4:	873e                	mv	a4,a5
    80200df6:	fb843783          	ld	a5,-72(s0)
    80200dfa:	e31c                	sd	a5,0(a4)
                }
            }
        }
        return address;
    80200dfc:	fb843783          	ld	a5,-72(s0)
    80200e00:	a445                	j	802010a0 <merge+0x354>
    } else if ((prev != 0) && (next == 0)) {
    80200e02:	fe843783          	ld	a5,-24(s0)
    80200e06:	c7a5                	beqz	a5,80200e6e <merge+0x122>
    80200e08:	fe043783          	ld	a5,-32(s0)
    80200e0c:	e3ad                	bnez	a5,80200e6e <merge+0x122>
        prev_alloc = PREV_ALLOC(address);
    80200e0e:	fb843783          	ld	a5,-72(s0)
    80200e12:	17c1                	addi	a5,a5,-16
    80200e14:	639c                	ld	a5,0(a5)
    80200e16:	17a1                	addi	a5,a5,-24
    80200e18:	639c                	ld	a5,0(a5)
    80200e1a:	8b85                	andi	a5,a5,1
    80200e1c:	fcf43423          	sd	a5,-56(s0)
        if (prev_alloc == 0) {
    80200e20:	fc843783          	ld	a5,-56(s0)
    80200e24:	e3b1                	bnez	a5,80200e68 <merge+0x11c>
            if (((uint64_t)prev & (~4095)) == ((uint64_t)address & (~4095))) {
    80200e26:	fe843703          	ld	a4,-24(s0)
    80200e2a:	fb843783          	ld	a5,-72(s0)
    80200e2e:	8f3d                	xor	a4,a4,a5
    80200e30:	77fd                	lui	a5,0xfffff
    80200e32:	8ff9                	and	a5,a5,a4
    80200e34:	eb95                	bnez	a5,80200e68 <merge+0x11c>
                size += GET_SIZE((void*)prev);
    80200e36:	fe843783          	ld	a5,-24(s0)
    80200e3a:	17a1                	addi	a5,a5,-24 # ffffffffffffefe8 <kernel_end+0xffffffff7faccfe8>
    80200e3c:	639c                	ld	a5,0(a5)
    80200e3e:	9be1                	andi	a5,a5,-8
    80200e40:	fd843703          	ld	a4,-40(s0)
    80200e44:	97ba                	add	a5,a5,a4
    80200e46:	fcf43c23          	sd	a5,-40(s0)
                PUT(HEAD((void*)prev), PACK(size, 0));
    80200e4a:	fe843783          	ld	a5,-24(s0)
    80200e4e:	17a1                	addi	a5,a5,-24
    80200e50:	fd843703          	ld	a4,-40(s0)
    80200e54:	9b61                	andi	a4,a4,-8
    80200e56:	e398                	sd	a4,0(a5)
                PUT(NEXT((void*)prev), 0);
    80200e58:	fe843783          	ld	a5,-24(s0)
    80200e5c:	17e1                	addi	a5,a5,-8
    80200e5e:	0007b023          	sd	zero,0(a5)
                return (void*)prev;
    80200e62:	fe843783          	ld	a5,-24(s0)
    80200e66:	ac2d                	j	802010a0 <merge+0x354>
            }
        }
        return address;
    80200e68:	fb843783          	ld	a5,-72(s0)
    80200e6c:	ac15                	j	802010a0 <merge+0x354>
    } else {
        prev_alloc = PREV_ALLOC(address);
    80200e6e:	fb843783          	ld	a5,-72(s0)
    80200e72:	17c1                	addi	a5,a5,-16
    80200e74:	639c                	ld	a5,0(a5)
    80200e76:	17a1                	addi	a5,a5,-24
    80200e78:	639c                	ld	a5,0(a5)
    80200e7a:	8b85                	andi	a5,a5,1
    80200e7c:	fcf43423          	sd	a5,-56(s0)
        next_alloc = NEXT_ALLOC(address);
    80200e80:	fb843783          	ld	a5,-72(s0)
    80200e84:	17e1                	addi	a5,a5,-8
    80200e86:	639c                	ld	a5,0(a5)
    80200e88:	17a1                	addi	a5,a5,-24
    80200e8a:	639c                	ld	a5,0(a5)
    80200e8c:	8b85                	andi	a5,a5,1
    80200e8e:	fcf43823          	sd	a5,-48(s0)
        if ((prev_alloc == 0) && (next_alloc == 0)) {
    80200e92:	fc843783          	ld	a5,-56(s0)
    80200e96:	12079963          	bnez	a5,80200fc8 <merge+0x27c>
    80200e9a:	fd043783          	ld	a5,-48(s0)
    80200e9e:	12079563          	bnez	a5,80200fc8 <merge+0x27c>
            if (((uint64_t)prev & (~4095)) == ((uint64_t)address & (~4095))) {
    80200ea2:	fe843703          	ld	a4,-24(s0)
    80200ea6:	fb843783          	ld	a5,-72(s0)
    80200eaa:	8f3d                	xor	a4,a4,a5
    80200eac:	77fd                	lui	a5,0xfffff
    80200eae:	8ff9                	and	a5,a5,a4
    80200eb0:	ebcd                	bnez	a5,80200f62 <merge+0x216>
                if (((uint64_t)prev & (~4095)) == ((uint64_t)next & (~4095))) {
    80200eb2:	fe843703          	ld	a4,-24(s0)
    80200eb6:	fe043783          	ld	a5,-32(s0)
    80200eba:	8f3d                	xor	a4,a4,a5
    80200ebc:	77fd                	lui	a5,0xfffff
    80200ebe:	8ff9                	and	a5,a5,a4
    80200ec0:	e3ad                	bnez	a5,80200f22 <merge+0x1d6>
                    size = GET_SIZE((void*)prev) + GET_SIZE((void*)next) + size;
    80200ec2:	fe843783          	ld	a5,-24(s0)
    80200ec6:	17a1                	addi	a5,a5,-24 # ffffffffffffefe8 <kernel_end+0xffffffff7faccfe8>
    80200ec8:	639c                	ld	a5,0(a5)
    80200eca:	ff87f713          	andi	a4,a5,-8
    80200ece:	fe043783          	ld	a5,-32(s0)
    80200ed2:	17a1                	addi	a5,a5,-24
    80200ed4:	639c                	ld	a5,0(a5)
    80200ed6:	9be1                	andi	a5,a5,-8
    80200ed8:	97ba                	add	a5,a5,a4
    80200eda:	fd843703          	ld	a4,-40(s0)
    80200ede:	97ba                	add	a5,a5,a4
    80200ee0:	fcf43c23          	sd	a5,-40(s0)
                    PUT(HEAD((void*)prev), PACK(size, 0));
    80200ee4:	fe843783          	ld	a5,-24(s0)
    80200ee8:	17a1                	addi	a5,a5,-24
    80200eea:	fd843703          	ld	a4,-40(s0)
    80200eee:	9b61                	andi	a4,a4,-8
    80200ef0:	e398                	sd	a4,0(a5)
                    PUT(NEXT((void*)prev), NEXT_ADDRESS(next));
    80200ef2:	fe043783          	ld	a5,-32(s0)
    80200ef6:	ff878713          	addi	a4,a5,-8
    80200efa:	fe843783          	ld	a5,-24(s0)
    80200efe:	17e1                	addi	a5,a5,-8
    80200f00:	6318                	ld	a4,0(a4)
    80200f02:	e398                	sd	a4,0(a5)
                    if (NEXT_ADDRESS((void*)next) != 0) {
    80200f04:	fe043783          	ld	a5,-32(s0)
    80200f08:	17e1                	addi	a5,a5,-8
    80200f0a:	639c                	ld	a5,0(a5)
    80200f0c:	cba1                	beqz	a5,80200f5c <merge+0x210>
                        PUT(PREV(NEXT_ADDRESS((void*)next)), prev);
    80200f0e:	fe043783          	ld	a5,-32(s0)
    80200f12:	17e1                	addi	a5,a5,-8
    80200f14:	639c                	ld	a5,0(a5)
    80200f16:	17c1                	addi	a5,a5,-16
    80200f18:	873e                	mv	a4,a5
    80200f1a:	fe843783          	ld	a5,-24(s0)
    80200f1e:	e31c                	sd	a5,0(a4)
    80200f20:	a835                	j	80200f5c <merge+0x210>
                    }
                } else {
                    size += GET_SIZE(prev);
    80200f22:	fe843783          	ld	a5,-24(s0)
    80200f26:	17a1                	addi	a5,a5,-24
    80200f28:	639c                	ld	a5,0(a5)
    80200f2a:	9be1                	andi	a5,a5,-8
    80200f2c:	fd843703          	ld	a4,-40(s0)
    80200f30:	97ba                	add	a5,a5,a4
    80200f32:	fcf43c23          	sd	a5,-40(s0)
                    PUT(HEAD((void*)prev), PACK(size, 0));
    80200f36:	fe843783          	ld	a5,-24(s0)
    80200f3a:	17a1                	addi	a5,a5,-24
    80200f3c:	fd843703          	ld	a4,-40(s0)
    80200f40:	9b61                	andi	a4,a4,-8
    80200f42:	e398                	sd	a4,0(a5)
                    PUT(NEXT((void*)prev), next);
    80200f44:	fe843783          	ld	a5,-24(s0)
    80200f48:	17e1                	addi	a5,a5,-8
    80200f4a:	fe043703          	ld	a4,-32(s0)
    80200f4e:	e398                	sd	a4,0(a5)
                    PUT(PREV((void*)next), prev);
    80200f50:	fe043783          	ld	a5,-32(s0)
    80200f54:	17c1                	addi	a5,a5,-16
    80200f56:	fe843703          	ld	a4,-24(s0)
    80200f5a:	e398                	sd	a4,0(a5)
                }
                return (void*)prev;
    80200f5c:	fe843783          	ld	a5,-24(s0)
    80200f60:	a281                	j	802010a0 <merge+0x354>
            } else {
                if (((uint64_t)address & (~4095)) == ((uint64_t)next & (~4095))) {
    80200f62:	fb843703          	ld	a4,-72(s0)
    80200f66:	fe043783          	ld	a5,-32(s0)
    80200f6a:	8f3d                	xor	a4,a4,a5
    80200f6c:	77fd                	lui	a5,0xfffff
    80200f6e:	8ff9                	and	a5,a5,a4
    80200f70:	eba9                	bnez	a5,80200fc2 <merge+0x276>
                    size += GET_SIZE((void*)next);
    80200f72:	fe043783          	ld	a5,-32(s0)
    80200f76:	17a1                	addi	a5,a5,-24 # ffffffffffffefe8 <kernel_end+0xffffffff7faccfe8>
    80200f78:	639c                	ld	a5,0(a5)
    80200f7a:	9be1                	andi	a5,a5,-8
    80200f7c:	fd843703          	ld	a4,-40(s0)
    80200f80:	97ba                	add	a5,a5,a4
    80200f82:	fcf43c23          	sd	a5,-40(s0)
                    PUT(HEAD(address), PACK(size, 0));
    80200f86:	fb843783          	ld	a5,-72(s0)
    80200f8a:	17a1                	addi	a5,a5,-24
    80200f8c:	fd843703          	ld	a4,-40(s0)
    80200f90:	9b61                	andi	a4,a4,-8
    80200f92:	e398                	sd	a4,0(a5)
                    PUT(NEXT(address), NEXT_ADDRESS((void*)next));
    80200f94:	fe043783          	ld	a5,-32(s0)
    80200f98:	ff878713          	addi	a4,a5,-8
    80200f9c:	fb843783          	ld	a5,-72(s0)
    80200fa0:	17e1                	addi	a5,a5,-8
    80200fa2:	6318                	ld	a4,0(a4)
    80200fa4:	e398                	sd	a4,0(a5)
                    if (NEXT_ADDRESS((void*)next) != 0) {
    80200fa6:	fe043783          	ld	a5,-32(s0)
    80200faa:	17e1                	addi	a5,a5,-8
    80200fac:	639c                	ld	a5,0(a5)
    80200fae:	cb91                	beqz	a5,80200fc2 <merge+0x276>
                        PUT(PREV(NEXT_ADDRESS((void*)next)), address);
    80200fb0:	fe043783          	ld	a5,-32(s0)
    80200fb4:	17e1                	addi	a5,a5,-8
    80200fb6:	639c                	ld	a5,0(a5)
    80200fb8:	17c1                	addi	a5,a5,-16
    80200fba:	873e                	mv	a4,a5
    80200fbc:	fb843783          	ld	a5,-72(s0)
    80200fc0:	e31c                	sd	a5,0(a4)
                    }
                }
                return address;
    80200fc2:	fb843783          	ld	a5,-72(s0)
    80200fc6:	a8e9                	j	802010a0 <merge+0x354>
            }
        } else if ((prev_alloc == 0) && (next_alloc)) {
    80200fc8:	fc843783          	ld	a5,-56(s0)
    80200fcc:	efb9                	bnez	a5,8020102a <merge+0x2de>
    80200fce:	fd043783          	ld	a5,-48(s0)
    80200fd2:	cfa1                	beqz	a5,8020102a <merge+0x2de>
            if (((uint64_t)prev & (~4095)) == ((uint64_t)address & (~4095))) {
    80200fd4:	fe843703          	ld	a4,-24(s0)
    80200fd8:	fb843783          	ld	a5,-72(s0)
    80200fdc:	8f3d                	xor	a4,a4,a5
    80200fde:	77fd                	lui	a5,0xfffff
    80200fe0:	8ff9                	and	a5,a5,a4
    80200fe2:	e3a9                	bnez	a5,80201024 <merge+0x2d8>
                size += GET_SIZE((void*)prev);
    80200fe4:	fe843783          	ld	a5,-24(s0)
    80200fe8:	17a1                	addi	a5,a5,-24 # ffffffffffffefe8 <kernel_end+0xffffffff7faccfe8>
    80200fea:	639c                	ld	a5,0(a5)
    80200fec:	9be1                	andi	a5,a5,-8
    80200fee:	fd843703          	ld	a4,-40(s0)
    80200ff2:	97ba                	add	a5,a5,a4
    80200ff4:	fcf43c23          	sd	a5,-40(s0)
                PUT(HEAD((void*)prev), PACK(size, 0));
    80200ff8:	fe843783          	ld	a5,-24(s0)
    80200ffc:	17a1                	addi	a5,a5,-24
    80200ffe:	fd843703          	ld	a4,-40(s0)
    80201002:	9b61                	andi	a4,a4,-8
    80201004:	e398                	sd	a4,0(a5)
                PUT(NEXT((void*)prev), next);
    80201006:	fe843783          	ld	a5,-24(s0)
    8020100a:	17e1                	addi	a5,a5,-8
    8020100c:	fe043703          	ld	a4,-32(s0)
    80201010:	e398                	sd	a4,0(a5)
                PUT(PREV((void*)next), prev);
    80201012:	fe043783          	ld	a5,-32(s0)
    80201016:	17c1                	addi	a5,a5,-16
    80201018:	fe843703          	ld	a4,-24(s0)
    8020101c:	e398                	sd	a4,0(a5)
                return (void*)prev;
    8020101e:	fe843783          	ld	a5,-24(s0)
    80201022:	a8bd                	j	802010a0 <merge+0x354>
            }
            return address;
    80201024:	fb843783          	ld	a5,-72(s0)
    80201028:	a8a5                	j	802010a0 <merge+0x354>
        } else if ((prev_alloc) && (next_alloc == 0)) {
    8020102a:	fc843783          	ld	a5,-56(s0)
    8020102e:	c7bd                	beqz	a5,8020109c <merge+0x350>
    80201030:	fd043783          	ld	a5,-48(s0)
    80201034:	e7a5                	bnez	a5,8020109c <merge+0x350>
            if (((uint64_t)next & (~4095)) == ((uint64_t)address & (~4095))) {
    80201036:	fe043703          	ld	a4,-32(s0)
    8020103a:	fb843783          	ld	a5,-72(s0)
    8020103e:	8f3d                	xor	a4,a4,a5
    80201040:	77fd                	lui	a5,0xfffff
    80201042:	8ff9                	and	a5,a5,a4
    80201044:	eba9                	bnez	a5,80201096 <merge+0x34a>
                size += GET_SIZE((void*)next);
    80201046:	fe043783          	ld	a5,-32(s0)
    8020104a:	17a1                	addi	a5,a5,-24 # ffffffffffffefe8 <kernel_end+0xffffffff7faccfe8>
    8020104c:	639c                	ld	a5,0(a5)
    8020104e:	9be1                	andi	a5,a5,-8
    80201050:	fd843703          	ld	a4,-40(s0)
    80201054:	97ba                	add	a5,a5,a4
    80201056:	fcf43c23          	sd	a5,-40(s0)
                PUT(HEAD(address), PACK(size, 0));
    8020105a:	fb843783          	ld	a5,-72(s0)
    8020105e:	17a1                	addi	a5,a5,-24
    80201060:	fd843703          	ld	a4,-40(s0)
    80201064:	9b61                	andi	a4,a4,-8
    80201066:	e398                	sd	a4,0(a5)
                PUT(NEXT(address), NEXT_ADDRESS((void*)next));
    80201068:	fe043783          	ld	a5,-32(s0)
    8020106c:	ff878713          	addi	a4,a5,-8
    80201070:	fb843783          	ld	a5,-72(s0)
    80201074:	17e1                	addi	a5,a5,-8
    80201076:	6318                	ld	a4,0(a4)
    80201078:	e398                	sd	a4,0(a5)
                if (NEXT_ADDRESS((void*)next) != 0) {
    8020107a:	fe043783          	ld	a5,-32(s0)
    8020107e:	17e1                	addi	a5,a5,-8
    80201080:	639c                	ld	a5,0(a5)
    80201082:	cb91                	beqz	a5,80201096 <merge+0x34a>
                    PUT(PREV(NEXT_ADDRESS((void*)next)), address);
    80201084:	fe043783          	ld	a5,-32(s0)
    80201088:	17e1                	addi	a5,a5,-8
    8020108a:	639c                	ld	a5,0(a5)
    8020108c:	17c1                	addi	a5,a5,-16
    8020108e:	873e                	mv	a4,a5
    80201090:	fb843783          	ld	a5,-72(s0)
    80201094:	e31c                	sd	a5,0(a4)
                }
            }
            return address;
    80201096:	fb843783          	ld	a5,-72(s0)
    8020109a:	a019                	j	802010a0 <merge+0x354>
        }
    }
    return address;
    8020109c:	fb843783          	ld	a5,-72(s0)
}
    802010a0:	853e                	mv	a0,a5
    802010a2:	6426                	ld	s0,72(sp)
    802010a4:	6161                	addi	sp,sp,80
    802010a6:	8082                	ret

00000000802010a8 <extend_heap>:

void*
extend_heap(void) {
    802010a8:	1101                	addi	sp,sp,-32
    802010aa:	ec06                	sd	ra,24(sp)
    802010ac:	e822                	sd	s0,16(sp)
    802010ae:	1000                	addi	s0,sp,32
    void* next_page = kalloc();
    802010b0:	fffff097          	auipc	ra,0xfffff
    802010b4:	6c4080e7          	jalr	1732(ra) # 80200774 <kalloc>
    802010b8:	fea43423          	sd	a0,-24(s0)
    // create_pages_map(kernel_pagetable, (address_t)next_page, (address_t)next_page, PAGE_SIZE, PTE_R | PTE_W);
    byte_t* new = (byte_t*)next_page + TSIZE;
    802010bc:	fe843783          	ld	a5,-24(s0)
    802010c0:	07e1                	addi	a5,a5,24
    802010c2:	fef43023          	sd	a5,-32(s0)
    PUT((void*)next_page, PACK(PAGE_SIZE, 0));
    802010c6:	fe843783          	ld	a5,-24(s0)
    802010ca:	6705                	lui	a4,0x1
    802010cc:	e398                	sd	a4,0(a5)
    PUT(PREV((void*)new), 0);
    802010ce:	fe043783          	ld	a5,-32(s0)
    802010d2:	17c1                	addi	a5,a5,-16
    802010d4:	0007b023          	sd	zero,0(a5)
    PUT(NEXT((void*)new), listp);
    802010d8:	fe043783          	ld	a5,-32(s0)
    802010dc:	17e1                	addi	a5,a5,-8
    802010de:	00014717          	auipc	a4,0x14
    802010e2:	ffa70713          	addi	a4,a4,-6 # 802150d8 <listp>
    802010e6:	6318                	ld	a4,0(a4)
    802010e8:	e398                	sd	a4,0(a5)
    listp = (address_t) new;
    802010ea:	fe043703          	ld	a4,-32(s0)
    802010ee:	00014797          	auipc	a5,0x14
    802010f2:	fea78793          	addi	a5,a5,-22 # 802150d8 <listp>
    802010f6:	e398                	sd	a4,0(a5)
    return (void*)new;
    802010f8:	fe043783          	ld	a5,-32(s0)
}
    802010fc:	853e                	mv	a0,a5
    802010fe:	60e2                	ld	ra,24(sp)
    80201100:	6442                	ld	s0,16(sp)
    80201102:	6105                	addi	sp,sp,32
    80201104:	8082                	ret

0000000080201106 <place>:
void
place(void* goal, uint64_t size) {
    80201106:	7139                	addi	sp,sp,-64
    80201108:	fc06                	sd	ra,56(sp)
    8020110a:	f822                	sd	s0,48(sp)
    8020110c:	0080                	addi	s0,sp,64
    8020110e:	fca43423          	sd	a0,-56(s0)
    80201112:	fcb43023          	sd	a1,-64(s0)
#ifdef DEBUG
    printf("hart: %d    function: place\n", r_tp());
    80201116:	fffff097          	auipc	ra,0xfffff
    8020111a:	4a4080e7          	jalr	1188(ra) # 802005ba <r_tp>
    8020111e:	87aa                	mv	a5,a0
    80201120:	85be                	mv	a1,a5
    80201122:	0000a517          	auipc	a0,0xa
    80201126:	03e50513          	addi	a0,a0,62 # 8020b160 <etext+0x160>
    8020112a:	00001097          	auipc	ra,0x1
    8020112e:	7c8080e7          	jalr	1992(ra) # 802028f2 <printf>
#endif
    uint64_t goal_size = GET_SIZE(goal);
    80201132:	fc843783          	ld	a5,-56(s0)
    80201136:	17a1                	addi	a5,a5,-24
    80201138:	639c                	ld	a5,0(a5)
    8020113a:	9be1                	andi	a5,a5,-8
    8020113c:	fef43423          	sd	a5,-24(s0)
    uint64_t free_size = goal_size - size;
    80201140:	fe843703          	ld	a4,-24(s0)
    80201144:	fc043783          	ld	a5,-64(s0)
    80201148:	40f707b3          	sub	a5,a4,a5
    8020114c:	fef43023          	sd	a5,-32(s0)
    byte_t* free;
    if (free_size > MIN_BLOCK) {
    80201150:	fe043703          	ld	a4,-32(s0)
    80201154:	02000793          	li	a5,32
    80201158:	06e7f263          	bgeu	a5,a4,802011bc <place+0xb6>
        free = goal - free_size;
    8020115c:	fe043783          	ld	a5,-32(s0)
    80201160:	40f007b3          	neg	a5,a5
    80201164:	fc843703          	ld	a4,-56(s0)
    80201168:	97ba                	add	a5,a5,a4
    8020116a:	fcf43c23          	sd	a5,-40(s0)
        PUT(HEAD((void*)free), PACK(free_size, 0));
    8020116e:	fd843783          	ld	a5,-40(s0)
    80201172:	17a1                	addi	a5,a5,-24
    80201174:	fe043703          	ld	a4,-32(s0)
    80201178:	9b61                	andi	a4,a4,-8
    8020117a:	e398                	sd	a4,0(a5)
        PUT(PREV((void*)free), goal);
    8020117c:	fd843783          	ld	a5,-40(s0)
    80201180:	17c1                	addi	a5,a5,-16
    80201182:	fc843703          	ld	a4,-56(s0)
    80201186:	e398                	sd	a4,0(a5)
        PUT(NEXT((void*)free), NEXT_ADDRESS(goal));
    80201188:	fc843783          	ld	a5,-56(s0)
    8020118c:	ff878713          	addi	a4,a5,-8
    80201190:	fd843783          	ld	a5,-40(s0)
    80201194:	17e1                	addi	a5,a5,-8
    80201196:	6318                	ld	a4,0(a4)
    80201198:	e398                	sd	a4,0(a5)
        PUT(NEXT(goal), free);
    8020119a:	fc843783          	ld	a5,-56(s0)
    8020119e:	17e1                	addi	a5,a5,-8
    802011a0:	fd843703          	ld	a4,-40(s0)
    802011a4:	e398                	sd	a4,0(a5)
        PUT(HEAD(goal), PACK(size, 1));
    802011a6:	fc043783          	ld	a5,-64(s0)
    802011aa:	ff87f713          	andi	a4,a5,-8
    802011ae:	fc843783          	ld	a5,-56(s0)
    802011b2:	17a1                	addi	a5,a5,-24
    802011b4:	00176713          	ori	a4,a4,1
    802011b8:	e398                	sd	a4,0(a5)
    } else {
        PUT(HEAD(goal), PACK(goal_size, 1));
    }
    return;
    802011ba:	a821                	j	802011d2 <place+0xcc>
        PUT(HEAD(goal), PACK(goal_size, 1));
    802011bc:	fe843783          	ld	a5,-24(s0)
    802011c0:	ff87f713          	andi	a4,a5,-8
    802011c4:	fc843783          	ld	a5,-56(s0)
    802011c8:	17a1                	addi	a5,a5,-24
    802011ca:	00176713          	ori	a4,a4,1
    802011ce:	e398                	sd	a4,0(a5)
    return;
    802011d0:	0001                	nop
}
    802011d2:	70e2                	ld	ra,56(sp)
    802011d4:	7442                	ld	s0,48(sp)
    802011d6:	6121                	addi	sp,sp,64
    802011d8:	8082                	ret

00000000802011da <find_first_fit>:

void*
find_first_fit(uint64_t size) {
    802011da:	7179                	addi	sp,sp,-48
    802011dc:	f422                	sd	s0,40(sp)
    802011de:	1800                	addi	s0,sp,48
    802011e0:	fca43c23          	sd	a0,-40(s0)
    byte_t* current_listp = (byte_t*)listp;
    802011e4:	00014797          	auipc	a5,0x14
    802011e8:	ef478793          	addi	a5,a5,-268 # 802150d8 <listp>
    802011ec:	639c                	ld	a5,0(a5)
    802011ee:	fef43423          	sd	a5,-24(s0)
    for (; current_listp != 0; current_listp = (byte_t*)NEXT_ADDRESS(current_listp)) {
    802011f2:	a005                	j	80201212 <find_first_fit+0x38>
        if (GET_SIZE(current_listp) >= size) {
    802011f4:	fe843783          	ld	a5,-24(s0)
    802011f8:	17a1                	addi	a5,a5,-24
    802011fa:	639c                	ld	a5,0(a5)
    802011fc:	9be1                	andi	a5,a5,-8
    802011fe:	fd843703          	ld	a4,-40(s0)
    80201202:	00e7fc63          	bgeu	a5,a4,8020121a <find_first_fit+0x40>
    for (; current_listp != 0; current_listp = (byte_t*)NEXT_ADDRESS(current_listp)) {
    80201206:	fe843783          	ld	a5,-24(s0)
    8020120a:	17e1                	addi	a5,a5,-8
    8020120c:	639c                	ld	a5,0(a5)
    8020120e:	fef43423          	sd	a5,-24(s0)
    80201212:	fe843783          	ld	a5,-24(s0)
    80201216:	fff9                	bnez	a5,802011f4 <find_first_fit+0x1a>
    80201218:	a011                	j	8020121c <find_first_fit+0x42>
            break;
    8020121a:	0001                	nop
        }
    }
    return current_listp;
    8020121c:	fe843783          	ld	a5,-24(s0)
}
    80201220:	853e                	mv	a0,a5
    80201222:	7422                	ld	s0,40(sp)
    80201224:	6145                	addi	sp,sp,48
    80201226:	8082                	ret

0000000080201228 <alloc_proc_mem>:
void
alloc_proc_mem(proc_t* p) {
    80201228:	7179                	addi	sp,sp,-48
    8020122a:	f406                	sd	ra,40(sp)
    8020122c:	f022                	sd	s0,32(sp)
    8020122e:	1800                	addi	s0,sp,48
    80201230:	fca43c23          	sd	a0,-40(s0)
    p->trapFrame = (trapFrame_t*)kalloc();
    80201234:	fffff097          	auipc	ra,0xfffff
    80201238:	540080e7          	jalr	1344(ra) # 80200774 <kalloc>
    8020123c:	872a                	mv	a4,a0
    8020123e:	fd843783          	ld	a5,-40(s0)
    80201242:	f798                	sd	a4,40(a5)
    p->upageTable = (pageTable_t)kalloc();
    80201244:	fffff097          	auipc	ra,0xfffff
    80201248:	530080e7          	jalr	1328(ra) # 80200774 <kalloc>
    8020124c:	872a                	mv	a4,a0
    8020124e:	fd843783          	ld	a5,-40(s0)
    80201252:	ef98                	sd	a4,24(a5)
    p->kpageTable = (pageTable_t)kalloc();
    80201254:	fffff097          	auipc	ra,0xfffff
    80201258:	520080e7          	jalr	1312(ra) # 80200774 <kalloc>
    8020125c:	872a                	mv	a4,a0
    8020125e:	fd843783          	ld	a5,-40(s0)
    80201262:	f398                	sd	a4,32(a5)

    byte_t* stack = (void*)kalloc();
    80201264:	fffff097          	auipc	ra,0xfffff
    80201268:	510080e7          	jalr	1296(ra) # 80200774 <kalloc>
    8020126c:	fea43423          	sd	a0,-24(s0)
    memset(p->kpageTable, 0, PAGE_SIZE);
    80201270:	fd843783          	ld	a5,-40(s0)
    80201274:	739c                	ld	a5,32(a5)
    80201276:	6605                	lui	a2,0x1
    80201278:	4581                	li	a1,0
    8020127a:	853e                	mv	a0,a5
    8020127c:	00002097          	auipc	ra,0x2
    80201280:	8aa080e7          	jalr	-1878(ra) # 80202b26 <memset>
    memset(p->upageTable, 0, PAGE_SIZE);
    80201284:	fd843783          	ld	a5,-40(s0)
    80201288:	6f9c                	ld	a5,24(a5)
    8020128a:	6605                	lui	a2,0x1
    8020128c:	4581                	li	a1,0
    8020128e:	853e                	mv	a0,a5
    80201290:	00002097          	auipc	ra,0x2
    80201294:	896080e7          	jalr	-1898(ra) # 80202b26 <memset>
    memset(p->trapFrame, 0, PAGE_SIZE);
    80201298:	fd843783          	ld	a5,-40(s0)
    8020129c:	779c                	ld	a5,40(a5)
    8020129e:	6605                	lui	a2,0x1
    802012a0:	4581                	li	a1,0
    802012a2:	853e                	mv	a0,a5
    802012a4:	00002097          	auipc	ra,0x2
    802012a8:	882080e7          	jalr	-1918(ra) # 80202b26 <memset>
    memmove(p->kpageTable, kernel_pagetable, PAGE_SIZE);
    802012ac:	fd843783          	ld	a5,-40(s0)
    802012b0:	7398                	ld	a4,32(a5)
    802012b2:	00014797          	auipc	a5,0x14
    802012b6:	e2e78793          	addi	a5,a5,-466 # 802150e0 <kernel_pagetable>
    802012ba:	639c                	ld	a5,0(a5)
    802012bc:	6605                	lui	a2,0x1
    802012be:	85be                	mv	a1,a5
    802012c0:	853a                	mv	a0,a4
    802012c2:	00002097          	auipc	ra,0x2
    802012c6:	8ba080e7          	jalr	-1862(ra) # 80202b7c <memmove>
    create_pages_map(p->upageTable, (address_t)TRAMPOLINE, (address_t)trampoline, PAGE_SIZE, (uint64_t)(PTE_R | PTE_X));
    802012ca:	fd843783          	ld	a5,-40(s0)
    802012ce:	6f88                	ld	a0,24(a5)
    802012d0:	00009797          	auipc	a5,0x9
    802012d4:	d3078793          	addi	a5,a5,-720 # 8020a000 <_trampoline>
    802012d8:	4729                	li	a4,10
    802012da:	6685                	lui	a3,0x1
    802012dc:	863e                	mv	a2,a5
    802012de:	040007b7          	lui	a5,0x4000
    802012e2:	17fd                	addi	a5,a5,-1 # 3ffffff <_entry-0x7c200001>
    802012e4:	00c79593          	slli	a1,a5,0xc
    802012e8:	fffff097          	auipc	ra,0xfffff
    802012ec:	6b0080e7          	jalr	1712(ra) # 80200998 <create_pages_map>
    create_pages_map(p->upageTable, (address_t)TRAP_FRAME, (address_t)p->trapFrame, PAGE_SIZE, (uint64_t)(PTE_R | PTE_W));
    802012f0:	fd843783          	ld	a5,-40(s0)
    802012f4:	6f88                	ld	a0,24(a5)
    802012f6:	fd843783          	ld	a5,-40(s0)
    802012fa:	779c                	ld	a5,40(a5)
    802012fc:	4719                	li	a4,6
    802012fe:	6685                	lui	a3,0x1
    80201300:	863e                	mv	a2,a5
    80201302:	020007b7          	lui	a5,0x2000
    80201306:	17fd                	addi	a5,a5,-1 # 1ffffff <_entry-0x7e200001>
    80201308:	00d79593          	slli	a1,a5,0xd
    8020130c:	fffff097          	auipc	ra,0xfffff
    80201310:	68c080e7          	jalr	1676(ra) # 80200998 <create_pages_map>
    //  create_pages_map(p->upageTable, (address_t)TRAMRET, (address_t)userret, PAGE_SIZE, (uint64_t)(PTE_R | PTE_X));
    create_pages_map(p->kpageTable, (address_t)UVK_STACK, (address_t)stack, PAGE_SIZE, (uint64_t)(PTE_R | PTE_W));
    80201314:	fd843783          	ld	a5,-40(s0)
    80201318:	7388                	ld	a0,32(a5)
    8020131a:	fe843783          	ld	a5,-24(s0)
    8020131e:	4719                	li	a4,6
    80201320:	6685                	lui	a3,0x1
    80201322:	863e                	mv	a2,a5
    80201324:	0fb00793          	li	a5,251
    80201328:	01e79593          	slli	a1,a5,0x1e
    8020132c:	fffff097          	auipc	ra,0xfffff
    80201330:	66c080e7          	jalr	1644(ra) # 80200998 <create_pages_map>
}
    80201334:	0001                	nop
    80201336:	70a2                	ld	ra,40(sp)
    80201338:	7402                	ld	s0,32(sp)
    8020133a:	6145                	addi	sp,sp,48
    8020133c:	8082                	ret

000000008020133e <uvminit>:

void
uvminit(pageTable_t pageTable, pageTable_t kpageTable, code_t* code, uint64_t size) {
    8020133e:	7139                	addi	sp,sp,-64
    80201340:	fc06                	sd	ra,56(sp)
    80201342:	f822                	sd	s0,48(sp)
    80201344:	0080                	addi	s0,sp,64
    80201346:	fca43c23          	sd	a0,-40(s0)
    8020134a:	fcb43823          	sd	a1,-48(s0)
    8020134e:	fcc43423          	sd	a2,-56(s0)
    80201352:	fcd43023          	sd	a3,-64(s0)
    void* mem = kalloc();
    80201356:	fffff097          	auipc	ra,0xfffff
    8020135a:	41e080e7          	jalr	1054(ra) # 80200774 <kalloc>
    8020135e:	fea43423          	sd	a0,-24(s0)
    memset(mem, 0, PAGE_SIZE);
    80201362:	6605                	lui	a2,0x1
    80201364:	4581                	li	a1,0
    80201366:	fe843503          	ld	a0,-24(s0)
    8020136a:	00001097          	auipc	ra,0x1
    8020136e:	7bc080e7          	jalr	1980(ra) # 80202b26 <memset>
    create_pages_map(pageTable, (address_t)UVA_START, (address_t)mem, PAGE_SIZE, PTE_W | PTE_R | PTE_X | PTE_U);
    80201372:	fe843783          	ld	a5,-24(s0)
    80201376:	4779                	li	a4,30
    80201378:	6685                	lui	a3,0x1
    8020137a:	863e                	mv	a2,a5
    8020137c:	4581                	li	a1,0
    8020137e:	fd843503          	ld	a0,-40(s0)
    80201382:	fffff097          	auipc	ra,0xfffff
    80201386:	616080e7          	jalr	1558(ra) # 80200998 <create_pages_map>
    create_pages_map(kpageTable, (address_t)UVA_START, (address_t)mem, PAGE_SIZE, PTE_W | PTE_R | PTE_X);
    8020138a:	fe843783          	ld	a5,-24(s0)
    8020138e:	4739                	li	a4,14
    80201390:	6685                	lui	a3,0x1
    80201392:	863e                	mv	a2,a5
    80201394:	4581                	li	a1,0
    80201396:	fd043503          	ld	a0,-48(s0)
    8020139a:	fffff097          	auipc	ra,0xfffff
    8020139e:	5fe080e7          	jalr	1534(ra) # 80200998 <create_pages_map>
    memmove(mem, code, size);
    802013a2:	fc043603          	ld	a2,-64(s0)
    802013a6:	fc843583          	ld	a1,-56(s0)
    802013aa:	fe843503          	ld	a0,-24(s0)
    802013ae:	00001097          	auipc	ra,0x1
    802013b2:	7ce080e7          	jalr	1998(ra) # 80202b7c <memmove>
}
    802013b6:	0001                	nop
    802013b8:	70e2                	ld	ra,56(sp)
    802013ba:	7442                	ld	s0,48(sp)
    802013bc:	6121                	addi	sp,sp,64
    802013be:	8082                	ret

00000000802013c0 <copy_to_kernel>:

int
copy_to_kernel(void* dst, void* src, size_t size) {}
    802013c0:	7179                	addi	sp,sp,-48
    802013c2:	f422                	sd	s0,40(sp)
    802013c4:	1800                	addi	s0,sp,48
    802013c6:	fea43423          	sd	a0,-24(s0)
    802013ca:	feb43023          	sd	a1,-32(s0)
    802013ce:	fcc43c23          	sd	a2,-40(s0)
    802013d2:	0001                	nop
    802013d4:	853e                	mv	a0,a5
    802013d6:	7422                	ld	s0,40(sp)
    802013d8:	6145                	addi	sp,sp,48
    802013da:	8082                	ret

00000000802013dc <uvmcopy>:

void
uvmcopy(proc_t* p, proc_t* newp) {
    802013dc:	715d                	addi	sp,sp,-80
    802013de:	e486                	sd	ra,72(sp)
    802013e0:	e0a2                	sd	s0,64(sp)
    802013e2:	0880                	addi	s0,sp,80
    802013e4:	faa43c23          	sd	a0,-72(s0)
    802013e8:	fab43823          	sd	a1,-80(s0)
    size_t old_size = p->size;
    802013ec:	fb843783          	ld	a5,-72(s0)
    802013f0:	5887b783          	ld	a5,1416(a5)
    802013f4:	fef43023          	sd	a5,-32(s0)
    for (size_t new_size = 0; new_size < old_size; new_size += PAGE_SIZE) {
    802013f8:	fe043423          	sd	zero,-24(s0)
    802013fc:	a8c1                	j	802014cc <uvmcopy+0xf0>
        void* new_mem = kalloc();
    802013fe:	fffff097          	auipc	ra,0xfffff
    80201402:	376080e7          	jalr	886(ra) # 80200774 <kalloc>
    80201406:	fca43c23          	sd	a0,-40(s0)
        pte_t* pte = get_level0_pte(p->upageTable, (address_t)new_size, 0);
    8020140a:	fb843783          	ld	a5,-72(s0)
    8020140e:	6f9c                	ld	a5,24(a5)
    80201410:	4601                	li	a2,0
    80201412:	fe843583          	ld	a1,-24(s0)
    80201416:	853e                	mv	a0,a5
    80201418:	fffff097          	auipc	ra,0xfffff
    8020141c:	650080e7          	jalr	1616(ra) # 80200a68 <get_level0_pte>
    80201420:	fca43823          	sd	a0,-48(s0)
        uint64_t flag = GET_FLAG(*(uint64_t*)pte);
    80201424:	fd043783          	ld	a5,-48(s0)
    80201428:	639c                	ld	a5,0(a5)
    8020142a:	3ff7f793          	andi	a5,a5,1023
    8020142e:	fcf43423          	sd	a5,-56(s0)
        address_t pa = GET_PA(new_size, *(uint64_t*)pte);
    80201432:	fe843703          	ld	a4,-24(s0)
    80201436:	6785                	lui	a5,0x1
    80201438:	17fd                	addi	a5,a5,-1 # fff <_entry-0x801ff001>
    8020143a:	8f7d                	and	a4,a4,a5
    8020143c:	fd043783          	ld	a5,-48(s0)
    80201440:	639c                	ld	a5,0(a5)
    80201442:	83a9                	srli	a5,a5,0xa
    80201444:	07b2                	slli	a5,a5,0xc
    80201446:	97ba                	add	a5,a5,a4
    80201448:	fcf43023          	sd	a5,-64(s0)
        if ((pa % 4096) != 0) {
    8020144c:	fc043703          	ld	a4,-64(s0)
    80201450:	6785                	lui	a5,0x1
    80201452:	17fd                	addi	a5,a5,-1 # fff <_entry-0x801ff001>
    80201454:	8ff9                	and	a5,a5,a4
    80201456:	cb91                	beqz	a5,8020146a <uvmcopy+0x8e>
            panic("uvmcpoy: pa is not aligned\n");
    80201458:	0000a517          	auipc	a0,0xa
    8020145c:	d2850513          	addi	a0,a0,-728 # 8020b180 <etext+0x180>
    80201460:	00001097          	auipc	ra,0x1
    80201464:	6a4080e7          	jalr	1700(ra) # 80202b04 <panic>
            while (1)
    80201468:	a001                	j	80201468 <uvmcopy+0x8c>
                ;
        }
        memmove(new_mem, (void*)pa, PAGE_SIZE);
    8020146a:	fc043783          	ld	a5,-64(s0)
    8020146e:	6605                	lui	a2,0x1
    80201470:	85be                	mv	a1,a5
    80201472:	fd843503          	ld	a0,-40(s0)
    80201476:	00001097          	auipc	ra,0x1
    8020147a:	706080e7          	jalr	1798(ra) # 80202b7c <memmove>
        create_pages_map(newp->kpageTable, (address_t)new_size, (address_t)new_mem, PAGE_SIZE, flag & (~PTE_U));
    8020147e:	fb043783          	ld	a5,-80(s0)
    80201482:	7388                	ld	a0,32(a5)
    80201484:	fd843603          	ld	a2,-40(s0)
    80201488:	fc843783          	ld	a5,-56(s0)
    8020148c:	9bbd                	andi	a5,a5,-17
    8020148e:	873e                	mv	a4,a5
    80201490:	6685                	lui	a3,0x1
    80201492:	fe843583          	ld	a1,-24(s0)
    80201496:	fffff097          	auipc	ra,0xfffff
    8020149a:	502080e7          	jalr	1282(ra) # 80200998 <create_pages_map>
        create_pages_map(newp->upageTable, (address_t)new_size, (address_t)new_mem, PAGE_SIZE, flag | PTE_U);
    8020149e:	fb043783          	ld	a5,-80(s0)
    802014a2:	6f88                	ld	a0,24(a5)
    802014a4:	fd843603          	ld	a2,-40(s0)
    802014a8:	fc843783          	ld	a5,-56(s0)
    802014ac:	0107e793          	ori	a5,a5,16
    802014b0:	873e                	mv	a4,a5
    802014b2:	6685                	lui	a3,0x1
    802014b4:	fe843583          	ld	a1,-24(s0)
    802014b8:	fffff097          	auipc	ra,0xfffff
    802014bc:	4e0080e7          	jalr	1248(ra) # 80200998 <create_pages_map>
    for (size_t new_size = 0; new_size < old_size; new_size += PAGE_SIZE) {
    802014c0:	fe843703          	ld	a4,-24(s0)
    802014c4:	6785                	lui	a5,0x1
    802014c6:	97ba                	add	a5,a5,a4
    802014c8:	fef43423          	sd	a5,-24(s0)
    802014cc:	fe843703          	ld	a4,-24(s0)
    802014d0:	fe043783          	ld	a5,-32(s0)
    802014d4:	f2f765e3          	bltu	a4,a5,802013fe <uvmcopy+0x22>
    }
    newp->cwd = p->cwd;
    802014d8:	fb843783          	ld	a5,-72(s0)
    802014dc:	7bd8                	ld	a4,176(a5)
    802014de:	fb043783          	ld	a5,-80(s0)
    802014e2:	fbd8                	sd	a4,176(a5)
    memmove((void*)newp->trapFrame, (void*)p->trapFrame, PAGE_SIZE);
    802014e4:	fb043783          	ld	a5,-80(s0)
    802014e8:	7798                	ld	a4,40(a5)
    802014ea:	fb843783          	ld	a5,-72(s0)
    802014ee:	779c                	ld	a5,40(a5)
    802014f0:	6605                	lui	a2,0x1
    802014f2:	85be                	mv	a1,a5
    802014f4:	853a                	mv	a0,a4
    802014f6:	00001097          	auipc	ra,0x1
    802014fa:	686080e7          	jalr	1670(ra) # 80202b7c <memmove>
    memmove((void*)newp->openFiles, (void*)p->openFiles, N_OPEN_FILE * sizeof(file_t*));
    802014fe:	fb043783          	ld	a5,-80(s0)
    80201502:	0b878713          	addi	a4,a5,184 # 10b8 <_entry-0x801fef48>
    80201506:	fb843783          	ld	a5,-72(s0)
    8020150a:	0b878793          	addi	a5,a5,184
    8020150e:	4b000613          	li	a2,1200
    80201512:	85be                	mv	a1,a5
    80201514:	853a                	mv	a0,a4
    80201516:	00001097          	auipc	ra,0x1
    8020151a:	666080e7          	jalr	1638(ra) # 80202b7c <memmove>
}
    8020151e:	0001                	nop
    80201520:	60a6                	ld	ra,72(sp)
    80201522:	6406                	ld	s0,64(sp)
    80201524:	6161                	addi	sp,sp,80
    80201526:	8082                	ret

0000000080201528 <loadseg>:

static int
loadseg(pageTable_t pageTable, address_t va, dirent_t* dir, int32_t off, size_t size) {
    80201528:	711d                	addi	sp,sp,-96
    8020152a:	ec86                	sd	ra,88(sp)
    8020152c:	e8a2                	sd	s0,80(sp)
    8020152e:	1080                	addi	s0,sp,96
    80201530:	fca43423          	sd	a0,-56(s0)
    80201534:	fcb43023          	sd	a1,-64(s0)
    80201538:	fac43c23          	sd	a2,-72(s0)
    8020153c:	87b6                	mv	a5,a3
    8020153e:	fae43423          	sd	a4,-88(s0)
    80201542:	faf42a23          	sw	a5,-76(s0)
    if ((va % PAGE_SIZE) != 0) {
    80201546:	fc043703          	ld	a4,-64(s0)
    8020154a:	6785                	lui	a5,0x1
    8020154c:	17fd                	addi	a5,a5,-1 # fff <_entry-0x801ff001>
    8020154e:	8ff9                	and	a5,a5,a4
    80201550:	cb91                	beqz	a5,80201564 <loadseg+0x3c>
        panic("loadseg: va is not aligned\n");
    80201552:	0000a517          	auipc	a0,0xa
    80201556:	c4e50513          	addi	a0,a0,-946 # 8020b1a0 <etext+0x1a0>
    8020155a:	00001097          	auipc	ra,0x1
    8020155e:	5aa080e7          	jalr	1450(ra) # 80202b04 <panic>
        while (1)
    80201562:	a001                	j	80201562 <loadseg+0x3a>
            ;
    }
    address_t pa = kvm_trans(va, pageTable);
    80201564:	fc843583          	ld	a1,-56(s0)
    80201568:	fc043503          	ld	a0,-64(s0)
    8020156c:	fffff097          	auipc	ra,0xfffff
    80201570:	628080e7          	jalr	1576(ra) # 80200b94 <kvm_trans>
    80201574:	fea43423          	sd	a0,-24(s0)
    for (size_t i = 0; i < size; i += PAGE_SIZE) {
    80201578:	fe043023          	sd	zero,-32(s0)
    8020157c:	a8b1                	j	802015d8 <loadseg+0xb0>
        size_t read_size = __MIN(size - i, PAGE_SIZE);
    8020157e:	fa843703          	ld	a4,-88(s0)
    80201582:	fe043783          	ld	a5,-32(s0)
    80201586:	40f707b3          	sub	a5,a4,a5
    8020158a:	6705                	lui	a4,0x1
    8020158c:	00f77363          	bgeu	a4,a5,80201592 <loadseg+0x6a>
    80201590:	6785                	lui	a5,0x1
    80201592:	fcf43c23          	sd	a5,-40(s0)
        __fat32_read(dir, 0, (void*)pa, off + i, &read_size);
    80201596:	fe843603          	ld	a2,-24(s0)
    8020159a:	fe043783          	ld	a5,-32(s0)
    8020159e:	0007871b          	sext.w	a4,a5
    802015a2:	fb442783          	lw	a5,-76(s0)
    802015a6:	9fb9                	addw	a5,a5,a4
    802015a8:	2781                	sext.w	a5,a5
    802015aa:	fd840713          	addi	a4,s0,-40
    802015ae:	86be                	mv	a3,a5
    802015b0:	4581                	li	a1,0
    802015b2:	fb843503          	ld	a0,-72(s0)
    802015b6:	00004097          	auipc	ra,0x4
    802015ba:	650080e7          	jalr	1616(ra) # 80205c06 <__fat32_read>
        pa += read_size;//TODO 是否应当修改pa值
    802015be:	fd843783          	ld	a5,-40(s0)
    802015c2:	fe843703          	ld	a4,-24(s0)
    802015c6:	97ba                	add	a5,a5,a4
    802015c8:	fef43423          	sd	a5,-24(s0)
    for (size_t i = 0; i < size; i += PAGE_SIZE) {
    802015cc:	fe043703          	ld	a4,-32(s0)
    802015d0:	6785                	lui	a5,0x1
    802015d2:	97ba                	add	a5,a5,a4
    802015d4:	fef43023          	sd	a5,-32(s0)
    802015d8:	fe043703          	ld	a4,-32(s0)
    802015dc:	fa843783          	ld	a5,-88(s0)
    802015e0:	f8f76fe3          	bltu	a4,a5,8020157e <loadseg+0x56>
    }
    return 0;
    802015e4:	4781                	li	a5,0
}
    802015e6:	853e                	mv	a0,a5
    802015e8:	60e6                	ld	ra,88(sp)
    802015ea:	6446                	ld	s0,80(sp)
    802015ec:	6125                	addi	sp,sp,96
    802015ee:	8082                	ret

00000000802015f0 <elf_load>:

void
elf_load(proc_t* p, char* path) {
    802015f0:	7131                	addi	sp,sp,-192
    802015f2:	fd06                	sd	ra,184(sp)
    802015f4:	f922                	sd	s0,176(sp)
    802015f6:	0180                	addi	s0,sp,192
    802015f8:	f4a43423          	sd	a0,-184(s0)
    802015fc:	f4b43023          	sd	a1,-192(s0)
    elf_head_t elf_head;
    pro_head_t pro_head;
    dirent_t* dir = __fat32_name(path);
    80201600:	f4043503          	ld	a0,-192(s0)
    80201604:	00006097          	auipc	ra,0x6
    80201608:	bd4080e7          	jalr	-1068(ra) # 802071d8 <__fat32_name>
    8020160c:	fea43023          	sd	a0,-32(s0)
    dentry_lock(dir);
    80201610:	fe043503          	ld	a0,-32(s0)
    80201614:	00004097          	auipc	ra,0x4
    80201618:	4d6080e7          	jalr	1238(ra) # 80205aea <dentry_lock>
    size_t elf_head_size = sizeof(elf_head);
    8020161c:	04000793          	li	a5,64
    80201620:	f4f43c23          	sd	a5,-168(s0)
    size_t pro_head_size = sizeof(pro_head);
    80201624:	03800793          	li	a5,56
    80201628:	f4f43823          	sd	a5,-176(s0)
    // TODO elf_head地址不对
    // address_t temp_addr = (address_t)kvm_trans((address_t)&elf_head, getCurrentProc()->kpageTable);
    address_t temp_addr = (address_t)&elf_head;
    8020162c:	f9840793          	addi	a5,s0,-104
    80201630:	fcf43c23          	sd	a5,-40(s0)
    if (__fat32_read(dir, 0, (void*)temp_addr, 0, &elf_head_size) < 0) {
    80201634:	fd843783          	ld	a5,-40(s0)
    80201638:	f5840713          	addi	a4,s0,-168
    8020163c:	4681                	li	a3,0
    8020163e:	863e                	mv	a2,a5
    80201640:	4581                	li	a1,0
    80201642:	fe043503          	ld	a0,-32(s0)
    80201646:	00004097          	auipc	ra,0x4
    8020164a:	5c0080e7          	jalr	1472(ra) # 80205c06 <__fat32_read>
    8020164e:	87aa                	mv	a5,a0
    80201650:	0007db63          	bgez	a5,80201666 <elf_load+0x76>
        panic("elf_load:read elf head wrong\n");
    80201654:	0000a517          	auipc	a0,0xa
    80201658:	b6c50513          	addi	a0,a0,-1172 # 8020b1c0 <etext+0x1c0>
    8020165c:	00001097          	auipc	ra,0x1
    80201660:	4a8080e7          	jalr	1192(ra) # 80202b04 <panic>
        while (1)
    80201664:	a001                	j	80201664 <elf_load+0x74>
            ;
    }
    p->trapFrame->u_pc = elf_head.entry;
    80201666:	f4843783          	ld	a5,-184(s0)
    8020166a:	779c                	ld	a5,40(a5)
    8020166c:	fb043703          	ld	a4,-80(s0)
    80201670:	ef98                	sd	a4,24(a5)
    if (elf_head.magic != ELF_MAGIC) {
    80201672:	f9842783          	lw	a5,-104(s0)
    80201676:	873e                	mv	a4,a5
    80201678:	464c47b7          	lui	a5,0x464c4
    8020167c:	57f78793          	addi	a5,a5,1407 # 464c457f <_entry-0x39d3ba81>
    80201680:	02f70663          	beq	a4,a5,802016ac <elf_load+0xbc>
        panic("elf_load: elf.magic wrong!\n");
    80201684:	0000a517          	auipc	a0,0xa
    80201688:	b5c50513          	addi	a0,a0,-1188 # 8020b1e0 <etext+0x1e0>
    8020168c:	00001097          	auipc	ra,0x1
    80201690:	478080e7          	jalr	1144(ra) # 80202b04 <panic>
        printf("elf.head: %x", elf_head.magic);
    80201694:	f9842783          	lw	a5,-104(s0)
    80201698:	85be                	mv	a1,a5
    8020169a:	0000a517          	auipc	a0,0xa
    8020169e:	b6650513          	addi	a0,a0,-1178 # 8020b200 <etext+0x200>
    802016a2:	00001097          	auipc	ra,0x1
    802016a6:	250080e7          	jalr	592(ra) # 802028f2 <printf>
        while (1)
    802016aa:	a001                	j	802016aa <elf_load+0xba>
            ;
    }
    // TODO pro_head地址不对
    // temp_addr = (address_t)kvm_trans((address_t)&pro_head, getCurrentProc()->kpageTable);
    temp_addr = (address_t)&pro_head;
    802016ac:	f6040793          	addi	a5,s0,-160
    802016b0:	fcf43c23          	sd	a5,-40(s0)
    for (int i = 0, off = elf_head.phoff; i < elf_head.phnum; i++, off += sizeof(pro_head)) {
    802016b4:	fe042623          	sw	zero,-20(s0)
    802016b8:	fb843783          	ld	a5,-72(s0)
    802016bc:	fef42423          	sw	a5,-24(s0)
    802016c0:	a049                	j	80201742 <elf_load+0x152>
        if (__fat32_read(dir, 0, (void*)temp_addr, off, &pro_head_size) < 0) {
    802016c2:	fd843783          	ld	a5,-40(s0)
    802016c6:	fe842683          	lw	a3,-24(s0)
    802016ca:	f5040713          	addi	a4,s0,-176
    802016ce:	863e                	mv	a2,a5
    802016d0:	4581                	li	a1,0
    802016d2:	fe043503          	ld	a0,-32(s0)
    802016d6:	00004097          	auipc	ra,0x4
    802016da:	530080e7          	jalr	1328(ra) # 80205c06 <__fat32_read>
    802016de:	87aa                	mv	a5,a0
    802016e0:	0007db63          	bgez	a5,802016f6 <elf_load+0x106>
            panic("elf_load: read program head wrong\n");
    802016e4:	0000a517          	auipc	a0,0xa
    802016e8:	b2c50513          	addi	a0,a0,-1236 # 8020b210 <etext+0x210>
    802016ec:	00001097          	auipc	ra,0x1
    802016f0:	418080e7          	jalr	1048(ra) # 80202b04 <panic>
            while (1)
    802016f4:	a001                	j	802016f4 <elf_load+0x104>
                ;
        }
        if (pro_head.type != ELF_PROG_LOAD)
    802016f6:	f6042783          	lw	a5,-160(s0)
    802016fa:	873e                	mv	a4,a5
    802016fc:	4785                	li	a5,1
    802016fe:	02f71563          	bne	a4,a5,80201728 <elf_load+0x138>
            continue;
        loadseg(p->kpageTable, pro_head.vaddr, dir, pro_head.off, pro_head.filesz);
    80201702:	f4843783          	ld	a5,-184(s0)
    80201706:	739c                	ld	a5,32(a5)
    80201708:	f7043583          	ld	a1,-144(s0)
    8020170c:	f6843703          	ld	a4,-152(s0)
    80201710:	0007069b          	sext.w	a3,a4
    80201714:	f8043703          	ld	a4,-128(s0)
    80201718:	fe043603          	ld	a2,-32(s0)
    8020171c:	853e                	mv	a0,a5
    8020171e:	00000097          	auipc	ra,0x0
    80201722:	e0a080e7          	jalr	-502(ra) # 80201528 <loadseg>
    80201726:	a011                	j	8020172a <elf_load+0x13a>
            continue;
    80201728:	0001                	nop
    for (int i = 0, off = elf_head.phoff; i < elf_head.phnum; i++, off += sizeof(pro_head)) {
    8020172a:	fec42783          	lw	a5,-20(s0)
    8020172e:	2785                	addiw	a5,a5,1
    80201730:	fef42623          	sw	a5,-20(s0)
    80201734:	fe842783          	lw	a5,-24(s0)
    80201738:	0387879b          	addiw	a5,a5,56
    8020173c:	2781                	sext.w	a5,a5
    8020173e:	fef42423          	sw	a5,-24(s0)
    80201742:	fd045783          	lhu	a5,-48(s0)
    80201746:	0007871b          	sext.w	a4,a5
    8020174a:	fec42783          	lw	a5,-20(s0)
    8020174e:	2781                	sext.w	a5,a5
    80201750:	f6e7c9e3          	blt	a5,a4,802016c2 <elf_load+0xd2>
    }
    dentry_unlock(dir);
    80201754:	fe043503          	ld	a0,-32(s0)
    80201758:	00004097          	auipc	ra,0x4
    8020175c:	3da080e7          	jalr	986(ra) # 80205b32 <dentry_unlock>
    __fat32_put(dir);  // TODO
    80201760:	fe043503          	ld	a0,-32(s0)
    80201764:	00005097          	auipc	ra,0x5
    80201768:	02a080e7          	jalr	42(ra) # 8020678e <__fat32_put>
}
    8020176c:	0001                	nop
    8020176e:	70ea                	ld	ra,184(sp)
    80201770:	744a                	ld	s0,176(sp)
    80201772:	6129                	addi	sp,sp,192
    80201774:	8082                	ret

0000000080201776 <vmunmap>:

void
vmunmap(pageTable_t pageTable, address_t va, size_t size) {
    80201776:	7139                	addi	sp,sp,-64
    80201778:	fc06                	sd	ra,56(sp)
    8020177a:	f822                	sd	s0,48(sp)
    8020177c:	0080                	addi	s0,sp,64
    8020177e:	fca43c23          	sd	a0,-40(s0)
    80201782:	fcb43823          	sd	a1,-48(s0)
    80201786:	fcc43423          	sd	a2,-56(s0)
    if ((size % 4096) != 0) {
    8020178a:	fc843703          	ld	a4,-56(s0)
    8020178e:	6785                	lui	a5,0x1
    80201790:	17fd                	addi	a5,a5,-1 # fff <_entry-0x801ff001>
    80201792:	8ff9                	and	a5,a5,a4
    80201794:	cb89                	beqz	a5,802017a6 <vmunmap+0x30>
        panic("vmunmap: size is not aligned\n");
    80201796:	0000a517          	auipc	a0,0xa
    8020179a:	aa250513          	addi	a0,a0,-1374 # 8020b238 <etext+0x238>
    8020179e:	00001097          	auipc	ra,0x1
    802017a2:	366080e7          	jalr	870(ra) # 80202b04 <panic>
    }
    if ((va % 4096) != 0) {
    802017a6:	fd043703          	ld	a4,-48(s0)
    802017aa:	6785                	lui	a5,0x1
    802017ac:	17fd                	addi	a5,a5,-1 # fff <_entry-0x801ff001>
    802017ae:	8ff9                	and	a5,a5,a4
    802017b0:	cb89                	beqz	a5,802017c2 <vmunmap+0x4c>
        panic("vmunmap: va is not aligned\n");
    802017b2:	0000a517          	auipc	a0,0xa
    802017b6:	aa650513          	addi	a0,a0,-1370 # 8020b258 <etext+0x258>
    802017ba:	00001097          	auipc	ra,0x1
    802017be:	34a080e7          	jalr	842(ra) # 80202b04 <panic>
    }
    for (size_t i = 0; i < size; i += PAGE_SIZE) {
    802017c2:	fe043423          	sd	zero,-24(s0)
    802017c6:	a825                	j	802017fe <vmunmap+0x88>
        address_t pa = kvm_trans(va + i, pageTable);
    802017c8:	fd043703          	ld	a4,-48(s0)
    802017cc:	fe843783          	ld	a5,-24(s0)
    802017d0:	97ba                	add	a5,a5,a4
    802017d2:	fd843583          	ld	a1,-40(s0)
    802017d6:	853e                	mv	a0,a5
    802017d8:	fffff097          	auipc	ra,0xfffff
    802017dc:	3bc080e7          	jalr	956(ra) # 80200b94 <kvm_trans>
    802017e0:	fea43023          	sd	a0,-32(s0)
        kfree((void*)pa);
    802017e4:	fe043783          	ld	a5,-32(s0)
    802017e8:	853e                	mv	a0,a5
    802017ea:	fffff097          	auipc	ra,0xfffff
    802017ee:	eca080e7          	jalr	-310(ra) # 802006b4 <kfree>
    for (size_t i = 0; i < size; i += PAGE_SIZE) {
    802017f2:	fe843703          	ld	a4,-24(s0)
    802017f6:	6785                	lui	a5,0x1
    802017f8:	97ba                	add	a5,a5,a4
    802017fa:	fef43423          	sd	a5,-24(s0)
    802017fe:	fe843703          	ld	a4,-24(s0)
    80201802:	fc843783          	ld	a5,-56(s0)
    80201806:	fcf761e3          	bltu	a4,a5,802017c8 <vmunmap+0x52>
    }
}
    8020180a:	0001                	nop
    8020180c:	0001                	nop
    8020180e:	70e2                	ld	ra,56(sp)
    80201810:	7442                	ld	s0,48(sp)
    80201812:	6121                	addi	sp,sp,64
    80201814:	8082                	ret

0000000080201816 <free_pageTable>:
void
free_pageTable(pageTable_t pageTable) {
    80201816:	7179                	addi	sp,sp,-48
    80201818:	f406                	sd	ra,40(sp)
    8020181a:	f022                	sd	s0,32(sp)
    8020181c:	1800                	addi	s0,sp,48
    8020181e:	fca43c23          	sd	a0,-40(s0)
    for (int i = 0; i < 512; i++) {
    80201822:	fe042623          	sw	zero,-20(s0)
    80201826:	a8a9                	j	80201880 <free_pageTable+0x6a>
        pte_t pte = pageTable[i];
    80201828:	fec42783          	lw	a5,-20(s0)
    8020182c:	078e                	slli	a5,a5,0x3
    8020182e:	fd843703          	ld	a4,-40(s0)
    80201832:	97ba                	add	a5,a5,a4
    80201834:	639c                	ld	a5,0(a5)
    80201836:	fef43023          	sd	a5,-32(s0)
        if ((pte & PTE_V) && ((pte & (PTE_R | PTE_W | PTE_X)) == 0)) {
    8020183a:	fe043783          	ld	a5,-32(s0)
    8020183e:	8b85                	andi	a5,a5,1
    80201840:	c79d                	beqz	a5,8020186e <free_pageTable+0x58>
    80201842:	fe043783          	ld	a5,-32(s0)
    80201846:	8bb9                	andi	a5,a5,14
    80201848:	e39d                	bnez	a5,8020186e <free_pageTable+0x58>
            free_pageTable((pageTable_t)(GET_PAGETABLE(pte)));
    8020184a:	fe043783          	ld	a5,-32(s0)
    8020184e:	83a9                	srli	a5,a5,0xa
    80201850:	07b2                	slli	a5,a5,0xc
    80201852:	853e                	mv	a0,a5
    80201854:	00000097          	auipc	ra,0x0
    80201858:	fc2080e7          	jalr	-62(ra) # 80201816 <free_pageTable>
            pageTable[i] = 0;
    8020185c:	fec42783          	lw	a5,-20(s0)
    80201860:	078e                	slli	a5,a5,0x3
    80201862:	fd843703          	ld	a4,-40(s0)
    80201866:	97ba                	add	a5,a5,a4
    80201868:	0007b023          	sd	zero,0(a5) # 1000 <_entry-0x801ff000>
    8020186c:	a029                	j	80201876 <free_pageTable+0x60>
        } else if (pte & PTE_V) {
    8020186e:	fe043783          	ld	a5,-32(s0)
    80201872:	8b85                	andi	a5,a5,1
    80201874:	ef99                	bnez	a5,80201892 <free_pageTable+0x7c>
    for (int i = 0; i < 512; i++) {
    80201876:	fec42783          	lw	a5,-20(s0)
    8020187a:	2785                	addiw	a5,a5,1
    8020187c:	fef42623          	sw	a5,-20(s0)
    80201880:	fec42783          	lw	a5,-20(s0)
    80201884:	0007871b          	sext.w	a4,a5
    80201888:	1ff00793          	li	a5,511
    8020188c:	f8e7dee3          	bge	a5,a4,80201828 <free_pageTable+0x12>
    80201890:	a011                	j	80201894 <free_pageTable+0x7e>
            break;
    80201892:	0001                	nop
        }
    }
    kfree((void*)pageTable);
    80201894:	fd843503          	ld	a0,-40(s0)
    80201898:	fffff097          	auipc	ra,0xfffff
    8020189c:	e1c080e7          	jalr	-484(ra) # 802006b4 <kfree>
}
    802018a0:	0001                	nop
    802018a2:	70a2                	ld	ra,40(sp)
    802018a4:	7402                	ld	s0,32(sp)
    802018a6:	6145                	addi	sp,sp,48
    802018a8:	8082                	ret

00000000802018aa <kvmfree>:
void
kvmfree(pageTable_t pageTable) {
    802018aa:	7139                	addi	sp,sp,-64
    802018ac:	fc06                	sd	ra,56(sp)
    802018ae:	f822                	sd	s0,48(sp)
    802018b0:	0080                	addi	s0,sp,64
    802018b2:	fca43423          	sd	a0,-56(s0)
    vmunmap(pageTable, UVK_STACK, PAGE_SIZE);
    802018b6:	6605                	lui	a2,0x1
    802018b8:	0fb00793          	li	a5,251
    802018bc:	01e79593          	slli	a1,a5,0x1e
    802018c0:	fc843503          	ld	a0,-56(s0)
    802018c4:	00000097          	auipc	ra,0x0
    802018c8:	eb2080e7          	jalr	-334(ra) # 80201776 <vmunmap>
    static int flag = 0;
    pageTable_t level0_pagetable = (pageTable_t)GET_PAGETABLE(pageTable[VPN(UVK_STACK, 0)]);
    802018cc:	fc843783          	ld	a5,-56(s0)
    802018d0:	639c                	ld	a5,0(a5)
    802018d2:	83a9                	srli	a5,a5,0xa
    802018d4:	07b2                	slli	a5,a5,0xc
    802018d6:	fcf43c23          	sd	a5,-40(s0)
    pageTable_t level1_pagetable = (pageTable_t)GET_PAGETABLE(pageTable[VPN(UVK_STACK, 1)]);
    802018da:	fc843783          	ld	a5,-56(s0)
    802018de:	639c                	ld	a5,0(a5)
    802018e0:	83a9                	srli	a5,a5,0xa
    802018e2:	07b2                	slli	a5,a5,0xc
    802018e4:	fcf43823          	sd	a5,-48(s0)
    if (flag == 0) {
    802018e8:	00013797          	auipc	a5,0x13
    802018ec:	7e878793          	addi	a5,a5,2024 # 802150d0 <flag.0>
    802018f0:	439c                	lw	a5,0(a5)
    802018f2:	10079863          	bnez	a5,80201a02 <kvmfree+0x158>
        flag = 1;
    802018f6:	00013797          	auipc	a5,0x13
    802018fa:	7da78793          	addi	a5,a5,2010 # 802150d0 <flag.0>
    802018fe:	4705                	li	a4,1
    80201900:	c398                	sw	a4,0(a5)
        int level0_page_num = 0;
    80201902:	fe042623          	sw	zero,-20(s0)
        int level1_page_num = 0;
    80201906:	fe042423          	sw	zero,-24(s0)
        for (int i = 0; i < 512; i++) {
    8020190a:	fe042223          	sw	zero,-28(s0)
    8020190e:	a81d                	j	80201944 <kvmfree+0x9a>
            if (level0_pagetable[i] & PTE_V) {
    80201910:	fe442783          	lw	a5,-28(s0)
    80201914:	078e                	slli	a5,a5,0x3
    80201916:	fd843703          	ld	a4,-40(s0)
    8020191a:	97ba                	add	a5,a5,a4
    8020191c:	639c                	ld	a5,0(a5)
    8020191e:	8b85                	andi	a5,a5,1
    80201920:	cf89                	beqz	a5,8020193a <kvmfree+0x90>
                level0_page_num++;
    80201922:	fec42783          	lw	a5,-20(s0)
    80201926:	2785                	addiw	a5,a5,1
    80201928:	fef42623          	sw	a5,-20(s0)
                if (level0_page_num > 1) {
    8020192c:	fec42783          	lw	a5,-20(s0)
    80201930:	0007871b          	sext.w	a4,a5
    80201934:	4785                	li	a5,1
    80201936:	02e7c063          	blt	a5,a4,80201956 <kvmfree+0xac>
        for (int i = 0; i < 512; i++) {
    8020193a:	fe442783          	lw	a5,-28(s0)
    8020193e:	2785                	addiw	a5,a5,1
    80201940:	fef42223          	sw	a5,-28(s0)
    80201944:	fe442783          	lw	a5,-28(s0)
    80201948:	0007871b          	sext.w	a4,a5
    8020194c:	1ff00793          	li	a5,511
    80201950:	fce7d0e3          	bge	a5,a4,80201910 <kvmfree+0x66>
    80201954:	a011                	j	80201958 <kvmfree+0xae>
                    break;
    80201956:	0001                	nop
                }
            }
        }
        if (level0_page_num == 1) {
    80201958:	fec42783          	lw	a5,-20(s0)
    8020195c:	0007871b          	sext.w	a4,a5
    80201960:	4785                	li	a5,1
    80201962:	06f71563          	bne	a4,a5,802019cc <kvmfree+0x122>
            kfree((void*)level0_pagetable);
    80201966:	fd843503          	ld	a0,-40(s0)
    8020196a:	fffff097          	auipc	ra,0xfffff
    8020196e:	d4a080e7          	jalr	-694(ra) # 802006b4 <kfree>
            flag = 2;
    80201972:	00013797          	auipc	a5,0x13
    80201976:	75e78793          	addi	a5,a5,1886 # 802150d0 <flag.0>
    8020197a:	4709                	li	a4,2
    8020197c:	c398                	sw	a4,0(a5)
            for (int i = 0; i < 512; i++) {
    8020197e:	fe042023          	sw	zero,-32(s0)
    80201982:	a81d                	j	802019b8 <kvmfree+0x10e>
                if (level1_pagetable[i] & PTE_V) {
    80201984:	fe042783          	lw	a5,-32(s0)
    80201988:	078e                	slli	a5,a5,0x3
    8020198a:	fd043703          	ld	a4,-48(s0)
    8020198e:	97ba                	add	a5,a5,a4
    80201990:	639c                	ld	a5,0(a5)
    80201992:	8b85                	andi	a5,a5,1
    80201994:	cf89                	beqz	a5,802019ae <kvmfree+0x104>
                    level1_page_num++;
    80201996:	fe842783          	lw	a5,-24(s0)
    8020199a:	2785                	addiw	a5,a5,1
    8020199c:	fef42423          	sw	a5,-24(s0)
                    if (level1_page_num > 1) {
    802019a0:	fe842783          	lw	a5,-24(s0)
    802019a4:	0007871b          	sext.w	a4,a5
    802019a8:	4785                	li	a5,1
    802019aa:	02e7c063          	blt	a5,a4,802019ca <kvmfree+0x120>
            for (int i = 0; i < 512; i++) {
    802019ae:	fe042783          	lw	a5,-32(s0)
    802019b2:	2785                	addiw	a5,a5,1
    802019b4:	fef42023          	sw	a5,-32(s0)
    802019b8:	fe042783          	lw	a5,-32(s0)
    802019bc:	0007871b          	sext.w	a4,a5
    802019c0:	1ff00793          	li	a5,511
    802019c4:	fce7d0e3          	bge	a5,a4,80201984 <kvmfree+0xda>
    802019c8:	a011                	j	802019cc <kvmfree+0x122>
                        break;
    802019ca:	0001                	nop
                    }
                }
            }
        }
        if ((level1_page_num == 1) && (level0_page_num == 1)) {
    802019cc:	fe842783          	lw	a5,-24(s0)
    802019d0:	0007871b          	sext.w	a4,a5
    802019d4:	4785                	li	a5,1
    802019d6:	06f71b63          	bne	a4,a5,80201a4c <kvmfree+0x1a2>
    802019da:	fec42783          	lw	a5,-20(s0)
    802019de:	0007871b          	sext.w	a4,a5
    802019e2:	4785                	li	a5,1
    802019e4:	06f71463          	bne	a4,a5,80201a4c <kvmfree+0x1a2>
            flag = 3;
    802019e8:	00013797          	auipc	a5,0x13
    802019ec:	6e878793          	addi	a5,a5,1768 # 802150d0 <flag.0>
    802019f0:	470d                	li	a4,3
    802019f2:	c398                	sw	a4,0(a5)
            kfree((void*)level1_pagetable);
    802019f4:	fd043503          	ld	a0,-48(s0)
    802019f8:	fffff097          	auipc	ra,0xfffff
    802019fc:	cbc080e7          	jalr	-836(ra) # 802006b4 <kfree>
    80201a00:	a0b1                	j	80201a4c <kvmfree+0x1a2>
        }
    } else if (flag == 2) {
    80201a02:	00013797          	auipc	a5,0x13
    80201a06:	6ce78793          	addi	a5,a5,1742 # 802150d0 <flag.0>
    80201a0a:	439c                	lw	a5,0(a5)
    80201a0c:	873e                	mv	a4,a5
    80201a0e:	4789                	li	a5,2
    80201a10:	00f71963          	bne	a4,a5,80201a22 <kvmfree+0x178>
        kfree((void*)level0_pagetable);
    80201a14:	fd843503          	ld	a0,-40(s0)
    80201a18:	fffff097          	auipc	ra,0xfffff
    80201a1c:	c9c080e7          	jalr	-868(ra) # 802006b4 <kfree>
    80201a20:	a035                	j	80201a4c <kvmfree+0x1a2>
    } else if (flag == 3) {
    80201a22:	00013797          	auipc	a5,0x13
    80201a26:	6ae78793          	addi	a5,a5,1710 # 802150d0 <flag.0>
    80201a2a:	439c                	lw	a5,0(a5)
    80201a2c:	873e                	mv	a4,a5
    80201a2e:	478d                	li	a5,3
    80201a30:	00f71e63          	bne	a4,a5,80201a4c <kvmfree+0x1a2>
        kfree((void*)level0_pagetable);
    80201a34:	fd843503          	ld	a0,-40(s0)
    80201a38:	fffff097          	auipc	ra,0xfffff
    80201a3c:	c7c080e7          	jalr	-900(ra) # 802006b4 <kfree>
        kfree((void*)level1_pagetable);
    80201a40:	fd043503          	ld	a0,-48(s0)
    80201a44:	fffff097          	auipc	ra,0xfffff
    80201a48:	c70080e7          	jalr	-912(ra) # 802006b4 <kfree>
    }

    kfree((void*)pageTable);
    80201a4c:	fc843503          	ld	a0,-56(s0)
    80201a50:	fffff097          	auipc	ra,0xfffff
    80201a54:	c64080e7          	jalr	-924(ra) # 802006b4 <kfree>
}
    80201a58:	0001                	nop
    80201a5a:	70e2                	ld	ra,56(sp)
    80201a5c:	7442                	ld	s0,48(sp)
    80201a5e:	6121                	addi	sp,sp,64
    80201a60:	8082                	ret

0000000080201a62 <uvmfree>:
void
uvmfree(proc_t* p) {
    80201a62:	1101                	addi	sp,sp,-32
    80201a64:	ec06                	sd	ra,24(sp)
    80201a66:	e822                	sd	s0,16(sp)
    80201a68:	1000                	addi	s0,sp,32
    80201a6a:	fea43423          	sd	a0,-24(s0)
    vmunmap(p->upageTable, 0, p->size);
    80201a6e:	fe843783          	ld	a5,-24(s0)
    80201a72:	6f98                	ld	a4,24(a5)
    80201a74:	fe843783          	ld	a5,-24(s0)
    80201a78:	5887b783          	ld	a5,1416(a5)
    80201a7c:	863e                	mv	a2,a5
    80201a7e:	4581                	li	a1,0
    80201a80:	853a                	mv	a0,a4
    80201a82:	00000097          	auipc	ra,0x0
    80201a86:	cf4080e7          	jalr	-780(ra) # 80201776 <vmunmap>
    if (p->heap) {
    80201a8a:	fe843783          	ld	a5,-24(s0)
    80201a8e:	5987b783          	ld	a5,1432(a5)
    80201a92:	cf99                	beqz	a5,80201ab0 <uvmfree+0x4e>
        vmunmap(p->upageTable, p->size, PAGE_SIZE);
    80201a94:	fe843783          	ld	a5,-24(s0)
    80201a98:	6f98                	ld	a4,24(a5)
    80201a9a:	fe843783          	ld	a5,-24(s0)
    80201a9e:	5887b783          	ld	a5,1416(a5)
    80201aa2:	6605                	lui	a2,0x1
    80201aa4:	85be                	mv	a1,a5
    80201aa6:	853a                	mv	a0,a4
    80201aa8:	00000097          	auipc	ra,0x0
    80201aac:	cce080e7          	jalr	-818(ra) # 80201776 <vmunmap>
    }
    free_pageTable(p->upageTable);
    80201ab0:	fe843783          	ld	a5,-24(s0)
    80201ab4:	6f9c                	ld	a5,24(a5)
    80201ab6:	853e                	mv	a0,a5
    80201ab8:	00000097          	auipc	ra,0x0
    80201abc:	d5e080e7          	jalr	-674(ra) # 80201816 <free_pageTable>
}
    80201ac0:	0001                	nop
    80201ac2:	60e2                	ld	ra,24(sp)
    80201ac4:	6442                	ld	s0,16(sp)
    80201ac6:	6105                	addi	sp,sp,32
    80201ac8:	8082                	ret

0000000080201aca <r_tp>:
{
    80201aca:	1101                	addi	sp,sp,-32
    80201acc:	ec22                	sd	s0,24(sp)
    80201ace:	1000                	addi	s0,sp,32
    asm volatile("mv %0, tp"
    80201ad0:	8792                	mv	a5,tp
    80201ad2:	fef43423          	sd	a5,-24(s0)
    return x;
    80201ad6:	fe843783          	ld	a5,-24(s0)
}
    80201ada:	853e                	mv	a0,a5
    80201adc:	6462                	ld	s0,24(sp)
    80201ade:	6105                	addi	sp,sp,32
    80201ae0:	8082                	ret

0000000080201ae2 <w_satp>:
w_satp(address_t satp_data) {
    80201ae2:	1101                	addi	sp,sp,-32
    80201ae4:	ec22                	sd	s0,24(sp)
    80201ae6:	1000                	addi	s0,sp,32
    80201ae8:	fea43423          	sd	a0,-24(s0)
    asm volatile("csrw satp, %0"
    80201aec:	fe843783          	ld	a5,-24(s0)
    80201af0:	18079073          	csrw	satp,a5
}
    80201af4:	0001                	nop
    80201af6:	6462                	ld	s0,24(sp)
    80201af8:	6105                	addi	sp,sp,32
    80201afa:	8082                	ret

0000000080201afc <sfenve_vma>:
sfenve_vma() {
    80201afc:	1141                	addi	sp,sp,-16
    80201afe:	e422                	sd	s0,8(sp)
    80201b00:	0800                	addi	s0,sp,16
    asm volatile("sfence.vma");
    80201b02:	12000073          	sfence.vma
}
    80201b06:	0001                	nop
    80201b08:	6422                	ld	s0,8(sp)
    80201b0a:	0141                	addi	sp,sp,16
    80201b0c:	8082                	ret

0000000080201b0e <r_time>:
}

//timer
static inline register_t
r_time()
{
    80201b0e:	1101                	addi	sp,sp,-32
    80201b10:	ec22                	sd	s0,24(sp)
    80201b12:	1000                	addi	s0,sp,32
    register_t x;
    asm volatile("rdtime %0"
    80201b14:	c01027f3          	rdtime	a5
    80201b18:	fef43423          	sd	a5,-24(s0)
                 : "=r"(x));
    return x;
    80201b1c:	fe843783          	ld	a5,-24(s0)
}
    80201b20:	853e                	mv	a0,a5
    80201b22:	6462                	ld	s0,24(sp)
    80201b24:	6105                	addi	sp,sp,32
    80201b26:	8082                	ret

0000000080201b28 <proc_init>:
    // 0x05, 0xd0, 0x08, 0x93,
    // 0x00, 0x00, 0x00, 0x73,
    0x93, 0x08, 0xd0, 0x05, 0x73, 0x00, 0x00, 0x00,
};
void
proc_init(void) {
    80201b28:	1101                	addi	sp,sp,-32
    80201b2a:	ec06                	sd	ra,24(sp)
    80201b2c:	e822                	sd	s0,16(sp)
    80201b2e:	1000                	addi	s0,sp,32
    proc_t* p;
    spinlock_init(&pid_lk, "pid");  // TODO自旋锁？
    80201b30:	00009597          	auipc	a1,0x9
    80201b34:	74858593          	addi	a1,a1,1864 # 8020b278 <etext+0x278>
    80201b38:	00026517          	auipc	a0,0x26
    80201b3c:	a6050513          	addi	a0,a0,-1440 # 80227598 <pid_lk>
    80201b40:	00003097          	auipc	ra,0x3
    80201b44:	de2080e7          	jalr	-542(ra) # 80204922 <spinlock_init>
    for (p = proc; p < &proc[NPROC]; p++) {
    80201b48:	00013797          	auipc	a5,0x13
    80201b4c:	5a078793          	addi	a5,a5,1440 # 802150e8 <proc>
    80201b50:	fef43423          	sd	a5,-24(s0)
    80201b54:	a805                	j	80201b84 <proc_init+0x5c>
        p->state = UNUSED;
    80201b56:	fe843783          	ld	a5,-24(s0)
    80201b5a:	0007a023          	sw	zero,0(a5)
        spinlock_init(&p->lk, "proc");
    80201b5e:	fe843783          	ld	a5,-24(s0)
    80201b62:	56878793          	addi	a5,a5,1384
    80201b66:	00009597          	auipc	a1,0x9
    80201b6a:	71a58593          	addi	a1,a1,1818 # 8020b280 <etext+0x280>
    80201b6e:	853e                	mv	a0,a5
    80201b70:	00003097          	auipc	ra,0x3
    80201b74:	db2080e7          	jalr	-590(ra) # 80204922 <spinlock_init>
    for (p = proc; p < &proc[NPROC]; p++) {
    80201b78:	fe843783          	ld	a5,-24(s0)
    80201b7c:	5d878793          	addi	a5,a5,1496
    80201b80:	fef43423          	sd	a5,-24(s0)
    80201b84:	fe843703          	ld	a4,-24(s0)
    80201b88:	00026797          	auipc	a5,0x26
    80201b8c:	99078793          	addi	a5,a5,-1648 # 80227518 <cpu>
    80201b90:	fcf763e3          	bltu	a4,a5,80201b56 <proc_init+0x2e>
    }
    cpu[0].lk_num = 0;
    80201b94:	00026797          	auipc	a5,0x26
    80201b98:	98478793          	addi	a5,a5,-1660 # 80227518 <cpu>
    80201b9c:	0607ac23          	sw	zero,120(a5)
    cpu[1].lk_num = 0;
    80201ba0:	00026797          	auipc	a5,0x26
    80201ba4:	97878793          	addi	a5,a5,-1672 # 80227518 <cpu>
    80201ba8:	0e07ac23          	sw	zero,248(a5)
    cpu[0].current_p = NULL;
    80201bac:	00026797          	auipc	a5,0x26
    80201bb0:	96c78793          	addi	a5,a5,-1684 # 80227518 <cpu>
    80201bb4:	0607b823          	sd	zero,112(a5)
    cpu[1].current_p = NULL;
    80201bb8:	00026797          	auipc	a5,0x26
    80201bbc:	96078793          	addi	a5,a5,-1696 # 80227518 <cpu>
    80201bc0:	0e07b823          	sd	zero,240(a5)
}
    80201bc4:	0001                	nop
    80201bc6:	60e2                	ld	ra,24(sp)
    80201bc8:	6442                	ld	s0,16(sp)
    80201bca:	6105                	addi	sp,sp,32
    80201bcc:	8082                	ret

0000000080201bce <getCurrentProc>:

proc_t*
getCurrentProc(void) {
    80201bce:	1101                	addi	sp,sp,-32
    80201bd0:	ec06                	sd	ra,24(sp)
    80201bd2:	e822                	sd	s0,16(sp)
    80201bd4:	1000                	addi	s0,sp,32
    intr_push();
    80201bd6:	00002097          	auipc	ra,0x2
    80201bda:	21a080e7          	jalr	538(ra) # 80203df0 <intr_push>
    proc_t* p = getCurrentCPU()->current_p;
    80201bde:	00000097          	auipc	ra,0x0
    80201be2:	650080e7          	jalr	1616(ra) # 8020222e <getCurrentCPU>
    80201be6:	87aa                	mv	a5,a0
    80201be8:	7bbc                	ld	a5,112(a5)
    80201bea:	fef43423          	sd	a5,-24(s0)
    intr_pop();
    80201bee:	00002097          	auipc	ra,0x2
    80201bf2:	180080e7          	jalr	384(ra) # 80203d6e <intr_pop>
    return p;
    80201bf6:	fe843783          	ld	a5,-24(s0)
}
    80201bfa:	853e                	mv	a0,a5
    80201bfc:	60e2                	ld	ra,24(sp)
    80201bfe:	6442                	ld	s0,16(sp)
    80201c00:	6105                	addi	sp,sp,32
    80201c02:	8082                	ret

0000000080201c04 <alloc_pid>:

pid_t
alloc_pid(void) {
    80201c04:	1101                	addi	sp,sp,-32
    80201c06:	ec06                	sd	ra,24(sp)
    80201c08:	e822                	sd	s0,16(sp)
    80201c0a:	1000                	addi	s0,sp,32
    uint32_t c_pid;
    spinlock_acquire(&pid_lk);
    80201c0c:	00026517          	auipc	a0,0x26
    80201c10:	98c50513          	addi	a0,a0,-1652 # 80227598 <pid_lk>
    80201c14:	00003097          	auipc	ra,0x3
    80201c18:	d3e080e7          	jalr	-706(ra) # 80204952 <spinlock_acquire>
    pid++;
    80201c1c:	00026797          	auipc	a5,0x26
    80201c20:	99878793          	addi	a5,a5,-1640 # 802275b4 <pid>
    80201c24:	439c                	lw	a5,0(a5)
    80201c26:	2785                	addiw	a5,a5,1
    80201c28:	0007871b          	sext.w	a4,a5
    80201c2c:	00026797          	auipc	a5,0x26
    80201c30:	98878793          	addi	a5,a5,-1656 # 802275b4 <pid>
    80201c34:	c398                	sw	a4,0(a5)
    c_pid = pid;
    80201c36:	00026797          	auipc	a5,0x26
    80201c3a:	97e78793          	addi	a5,a5,-1666 # 802275b4 <pid>
    80201c3e:	439c                	lw	a5,0(a5)
    80201c40:	fef42623          	sw	a5,-20(s0)
    spinlock_release(&pid_lk);
    80201c44:	00026517          	auipc	a0,0x26
    80201c48:	95450513          	addi	a0,a0,-1708 # 80227598 <pid_lk>
    80201c4c:	00003097          	auipc	ra,0x3
    80201c50:	d7c080e7          	jalr	-644(ra) # 802049c8 <spinlock_release>
    return c_pid;
    80201c54:	fec42783          	lw	a5,-20(s0)
}
    80201c58:	853e                	mv	a0,a5
    80201c5a:	60e2                	ld	ra,24(sp)
    80201c5c:	6442                	ld	s0,16(sp)
    80201c5e:	6105                	addi	sp,sp,32
    80201c60:	8082                	ret

0000000080201c62 <entry_user_space>:

void
entry_user_space(void) {
    80201c62:	1101                	addi	sp,sp,-32
    80201c64:	ec06                	sd	ra,24(sp)
    80201c66:	e822                	sd	s0,16(sp)
    80201c68:	1000                	addi	s0,sp,32
    static int flag = 0;
    proc_t* p = getCurrentProc();
    80201c6a:	00000097          	auipc	ra,0x0
    80201c6e:	f64080e7          	jalr	-156(ra) # 80201bce <getCurrentProc>
    80201c72:	fea43423          	sd	a0,-24(s0)
    spinlock_release(&p->lk);
    80201c76:	fe843783          	ld	a5,-24(s0)
    80201c7a:	56878793          	addi	a5,a5,1384
    80201c7e:	853e                	mv	a0,a5
    80201c80:	00003097          	auipc	ra,0x3
    80201c84:	d48080e7          	jalr	-696(ra) # 802049c8 <spinlock_release>
    if (flag == 0) {
    80201c88:	00026797          	auipc	a5,0x26
    80201c8c:	92878793          	addi	a5,a5,-1752 # 802275b0 <flag.0>
    80201c90:	439c                	lw	a5,0(a5)
    80201c92:	e395                	bnez	a5,80201cb6 <entry_user_space+0x54>
        fat32_init();
    80201c94:	00005097          	auipc	ra,0x5
    80201c98:	59e080e7          	jalr	1438(ra) # 80207232 <fat32_init>
        flag = 1;
    80201c9c:	00026797          	auipc	a5,0x26
    80201ca0:	91478793          	addi	a5,a5,-1772 # 802275b0 <flag.0>
    80201ca4:	4705                	li	a4,1
    80201ca6:	c398                	sw	a4,0(a5)
        runOver = TRUE;
    80201ca8:	0000b797          	auipc	a5,0xb
    80201cac:	d0878793          	addi	a5,a5,-760 # 8020c9b0 <runOver>
    80201cb0:	4705                	li	a4,1
    80201cb2:	c398                	sw	a4,0(a5)
    80201cb4:	a015                	j	80201cd8 <entry_user_space+0x76>
    } else {
        elf_load(p, p->path);
    80201cb6:	fe843783          	ld	a5,-24(s0)
    80201cba:	5d07b783          	ld	a5,1488(a5)
    80201cbe:	85be                	mv	a1,a5
    80201cc0:	fe843503          	ld	a0,-24(s0)
    80201cc4:	00000097          	auipc	ra,0x0
    80201cc8:	92c080e7          	jalr	-1748(ra) # 802015f0 <elf_load>
        runOver = TRUE;
    80201ccc:	0000b797          	auipc	a5,0xb
    80201cd0:	ce478793          	addi	a5,a5,-796 # 8020c9b0 <runOver>
    80201cd4:	4705                	li	a4,1
    80201cd6:	c398                	sw	a4,0(a5)
    }
    usertrapret();
    80201cd8:	00002097          	auipc	ra,0x2
    80201cdc:	d1c080e7          	jalr	-740(ra) # 802039f4 <usertrapret>
}
    80201ce0:	0001                	nop
    80201ce2:	60e2                	ld	ra,24(sp)
    80201ce4:	6442                	ld	s0,16(sp)
    80201ce6:	6105                	addi	sp,sp,32
    80201ce8:	8082                	ret

0000000080201cea <alloc_proc>:

proc_t*
alloc_proc(void) {
    80201cea:	1101                	addi	sp,sp,-32
    80201cec:	ec06                	sd	ra,24(sp)
    80201cee:	e822                	sd	s0,16(sp)
    80201cf0:	1000                	addi	s0,sp,32
    proc_t* p;
    for (p = proc; p < proc + NPROC; ++p) {
    80201cf2:	00013797          	auipc	a5,0x13
    80201cf6:	3f678793          	addi	a5,a5,1014 # 802150e8 <proc>
    80201cfa:	fef43423          	sd	a5,-24(s0)
    80201cfe:	a82d                	j	80201d38 <alloc_proc+0x4e>
        spinlock_acquire(&p->lk);
    80201d00:	fe843783          	ld	a5,-24(s0)
    80201d04:	56878793          	addi	a5,a5,1384
    80201d08:	853e                	mv	a0,a5
    80201d0a:	00003097          	auipc	ra,0x3
    80201d0e:	c48080e7          	jalr	-952(ra) # 80204952 <spinlock_acquire>
        if (p->state == UNUSED)
    80201d12:	fe843783          	ld	a5,-24(s0)
    80201d16:	439c                	lw	a5,0(a5)
    80201d18:	cb8d                	beqz	a5,80201d4a <alloc_proc+0x60>
            break;
        spinlock_release(&p->lk);
    80201d1a:	fe843783          	ld	a5,-24(s0)
    80201d1e:	56878793          	addi	a5,a5,1384
    80201d22:	853e                	mv	a0,a5
    80201d24:	00003097          	auipc	ra,0x3
    80201d28:	ca4080e7          	jalr	-860(ra) # 802049c8 <spinlock_release>
    for (p = proc; p < proc + NPROC; ++p) {
    80201d2c:	fe843783          	ld	a5,-24(s0)
    80201d30:	5d878793          	addi	a5,a5,1496
    80201d34:	fef43423          	sd	a5,-24(s0)
    80201d38:	00025797          	auipc	a5,0x25
    80201d3c:	7e078793          	addi	a5,a5,2016 # 80227518 <cpu>
    80201d40:	fe843703          	ld	a4,-24(s0)
    80201d44:	faf76ee3          	bltu	a4,a5,80201d00 <alloc_proc+0x16>
    80201d48:	a011                	j	80201d4c <alloc_proc+0x62>
            break;
    80201d4a:	0001                	nop
    }
    // TODO p可能没找到，后续赋值非法
    p->state = NEW;
    80201d4c:	fe843783          	ld	a5,-24(s0)
    80201d50:	4705                	li	a4,1
    80201d52:	c398                	sw	a4,0(a5)
    spinlock_release(&p->lk);
    80201d54:	fe843783          	ld	a5,-24(s0)
    80201d58:	56878793          	addi	a5,a5,1384
    80201d5c:	853e                	mv	a0,a5
    80201d5e:	00003097          	auipc	ra,0x3
    80201d62:	c6a080e7          	jalr	-918(ra) # 802049c8 <spinlock_release>
    p->pid = alloc_pid();
    80201d66:	00000097          	auipc	ra,0x0
    80201d6a:	e9e080e7          	jalr	-354(ra) # 80201c04 <alloc_pid>
    80201d6e:	87aa                	mv	a5,a0
    80201d70:	873e                	mv	a4,a5
    80201d72:	fe843783          	ld	a5,-24(s0)
    80201d76:	c7d8                	sw	a4,12(a5)
    alloc_proc_mem(p);
    80201d78:	fe843503          	ld	a0,-24(s0)
    80201d7c:	fffff097          	auipc	ra,0xfffff
    80201d80:	4ac080e7          	jalr	1196(ra) # 80201228 <alloc_proc_mem>
    p->kstack = (void*)UVK_STACK;
    80201d84:	fe843783          	ld	a5,-24(s0)
    80201d88:	0fb00713          	li	a4,251
    80201d8c:	077a                	slli	a4,a4,0x1e
    80201d8e:	f3d8                	sd	a4,160(a5)
    memset(&p->context, 0, sizeof(p->context));
    80201d90:	fe843783          	ld	a5,-24(s0)
    80201d94:	03078793          	addi	a5,a5,48
    80201d98:	07000613          	li	a2,112
    80201d9c:	4581                	li	a1,0
    80201d9e:	853e                	mv	a0,a5
    80201da0:	00001097          	auipc	ra,0x1
    80201da4:	d86080e7          	jalr	-634(ra) # 80202b26 <memset>
    p->context.ra = (uint64_t)entry_user_space;
    80201da8:	00000717          	auipc	a4,0x0
    80201dac:	eba70713          	addi	a4,a4,-326 # 80201c62 <entry_user_space>
    80201db0:	fe843783          	ld	a5,-24(s0)
    80201db4:	fb98                	sd	a4,48(a5)
    p->context.sp = (address_t)p->kstack + PAGE_SIZE;
    80201db6:	fe843783          	ld	a5,-24(s0)
    80201dba:	73dc                	ld	a5,160(a5)
    80201dbc:	873e                	mv	a4,a5
    80201dbe:	6785                	lui	a5,0x1
    80201dc0:	973e                	add	a4,a4,a5
    80201dc2:	fe843783          	ld	a5,-24(s0)
    80201dc6:	ff98                	sd	a4,56(a5)
    // p->cwd = __fat32_name("/");
    p->cwd = &root;
    80201dc8:	fe843783          	ld	a5,-24(s0)
    80201dcc:	00329717          	auipc	a4,0x329
    80201dd0:	23c70713          	addi	a4,a4,572 # 8052b008 <root>
    80201dd4:	fbd8                	sd	a4,176(a5)
    p->openFiles[STDIN] = (file_t*)STDIN_PTR;
    80201dd6:	fe843783          	ld	a5,-24(s0)
    80201dda:	4705                	li	a4,1
    80201ddc:	171e                	slli	a4,a4,0x27
    80201dde:	ffd8                	sd	a4,184(a5)
    p->openFiles[STDOUT] = (file_t*)STDOUT_PTR;
    80201de0:	fe843783          	ld	a5,-24(s0)
    80201de4:	4705                	li	a4,1
    80201de6:	1722                	slli	a4,a4,0x28
    80201de8:	e3f8                	sd	a4,192(a5)
    p->openFiles[STDERR] = (file_t*)STDERR_PTR;
    80201dea:	fe843783          	ld	a5,-24(s0)
    80201dee:	4705                	li	a4,1
    80201df0:	1726                	slli	a4,a4,0x29
    80201df2:	e7f8                	sd	a4,200(a5)
    p->isForked = 0;
    80201df4:	fe843783          	ld	a5,-24(s0)
    80201df8:	58079823          	sh	zero,1424(a5) # 1590 <_entry-0x801fea70>
    p->heap = NULL;
    80201dfc:	fe843783          	ld	a5,-24(s0)
    80201e00:	5807bc23          	sd	zero,1432(a5)
    p->chan = NULL;
    80201e04:	fe843783          	ld	a5,-24(s0)
    80201e08:	0007b823          	sd	zero,16(a5)
    p->tms.tms_cstime = 0;
    80201e0c:	fe843783          	ld	a5,-24(s0)
    80201e10:	5a07bc23          	sd	zero,1464(a5)
    p->tms.tms_cutime = 0;
    80201e14:	fe843783          	ld	a5,-24(s0)
    80201e18:	5a07b823          	sd	zero,1456(a5)
    p->tms.tms_stime = 0;
    80201e1c:	fe843783          	ld	a5,-24(s0)
    80201e20:	5a07b423          	sd	zero,1448(a5)
    p->tms.tms_utime = 0;
    80201e24:	fe843783          	ld	a5,-24(s0)
    80201e28:	5a07b023          	sd	zero,1440(a5)
    p->tms.entry_kernel = 0;
    80201e2c:	fe843783          	ld	a5,-24(s0)
    80201e30:	5c07b023          	sd	zero,1472(a5)
    p->tms.leave_kernel = 0;
    80201e34:	fe843783          	ld	a5,-24(s0)
    80201e38:	5c07b423          	sd	zero,1480(a5)
    return p;
    80201e3c:	fe843783          	ld	a5,-24(s0)
}
    80201e40:	853e                	mv	a0,a5
    80201e42:	60e2                	ld	ra,24(sp)
    80201e44:	6442                	ld	s0,16(sp)
    80201e46:	6105                	addi	sp,sp,32
    80201e48:	8082                	ret

0000000080201e4a <creat_first_proc>:

void
creat_first_proc(void) {
    80201e4a:	1101                	addi	sp,sp,-32
    80201e4c:	ec06                	sd	ra,24(sp)
    80201e4e:	e822                	sd	s0,16(sp)
    80201e50:	1000                	addi	s0,sp,32
    proc_t* p;
    p = alloc_proc();
    80201e52:	00000097          	auipc	ra,0x0
    80201e56:	e98080e7          	jalr	-360(ra) # 80201cea <alloc_proc>
    80201e5a:	fea43423          	sd	a0,-24(s0)
    uvminit(p->upageTable, p->kpageTable, initcode, (uint64_t)sizeof(initcode));
    80201e5e:	fe843783          	ld	a5,-24(s0)
    80201e62:	6f98                	ld	a4,24(a5)
    80201e64:	fe843783          	ld	a5,-24(s0)
    80201e68:	739c                	ld	a5,32(a5)
    80201e6a:	46a1                	li	a3,8
    80201e6c:	0000b617          	auipc	a2,0xb
    80201e70:	b4c60613          	addi	a2,a2,-1204 # 8020c9b8 <initcode>
    80201e74:	85be                	mv	a1,a5
    80201e76:	853a                	mv	a0,a4
    80201e78:	fffff097          	auipc	ra,0xfffff
    80201e7c:	4c6080e7          	jalr	1222(ra) # 8020133e <uvminit>
    p->trapFrame->sp = PAGE_SIZE;
    80201e80:	fe843783          	ld	a5,-24(s0)
    80201e84:	779c                	ld	a5,40(a5)
    80201e86:	6705                	lui	a4,0x1
    80201e88:	fb98                	sd	a4,48(a5)
    p->trapFrame->u_pc = 0x0;
    80201e8a:	fe843783          	ld	a5,-24(s0)
    80201e8e:	779c                	ld	a5,40(a5)
    80201e90:	0007bc23          	sd	zero,24(a5)
    p->state = READY;
    80201e94:	fe843783          	ld	a5,-24(s0)
    80201e98:	4709                	li	a4,2
    80201e9a:	c398                	sw	a4,0(a5)
}
    80201e9c:	0001                	nop
    80201e9e:	60e2                	ld	ra,24(sp)
    80201ea0:	6442                	ld	s0,16(sp)
    80201ea2:	6105                	addi	sp,sp,32
    80201ea4:	8082                	ret

0000000080201ea6 <freeproc>:

void
freeproc(proc_t* p) {
    80201ea6:	1101                	addi	sp,sp,-32
    80201ea8:	ec06                	sd	ra,24(sp)
    80201eaa:	e822                	sd	s0,16(sp)
    80201eac:	1000                	addi	s0,sp,32
    80201eae:	fea43423          	sd	a0,-24(s0)
    if (p->trapFrame)
    80201eb2:	fe843783          	ld	a5,-24(s0)
    80201eb6:	779c                	ld	a5,40(a5)
    80201eb8:	cb89                	beqz	a5,80201eca <freeproc+0x24>
        kfree((void*)p->trapFrame);
    80201eba:	fe843783          	ld	a5,-24(s0)
    80201ebe:	779c                	ld	a5,40(a5)
    80201ec0:	853e                	mv	a0,a5
    80201ec2:	ffffe097          	auipc	ra,0xffffe
    80201ec6:	7f2080e7          	jalr	2034(ra) # 802006b4 <kfree>
    p->trapFrame = NULL;
    80201eca:	fe843783          	ld	a5,-24(s0)
    80201ece:	0207b423          	sd	zero,40(a5)
    if (p->kpageTable) {
    80201ed2:	fe843783          	ld	a5,-24(s0)
    80201ed6:	739c                	ld	a5,32(a5)
    80201ed8:	cb89                	beqz	a5,80201eea <freeproc+0x44>
        kvmfree(p->kpageTable);
    80201eda:	fe843783          	ld	a5,-24(s0)
    80201ede:	739c                	ld	a5,32(a5)
    80201ee0:	853e                	mv	a0,a5
    80201ee2:	00000097          	auipc	ra,0x0
    80201ee6:	9c8080e7          	jalr	-1592(ra) # 802018aa <kvmfree>
    }
    p->kpageTable = NULL;
    80201eea:	fe843783          	ld	a5,-24(s0)
    80201eee:	0207b023          	sd	zero,32(a5)
    if (p->upageTable) {
    80201ef2:	fe843783          	ld	a5,-24(s0)
    80201ef6:	6f9c                	ld	a5,24(a5)
    80201ef8:	c799                	beqz	a5,80201f06 <freeproc+0x60>
        uvmfree(p);
    80201efa:	fe843503          	ld	a0,-24(s0)
    80201efe:	00000097          	auipc	ra,0x0
    80201f02:	b64080e7          	jalr	-1180(ra) # 80201a62 <uvmfree>
    }
    p->upageTable = NULL;
    80201f06:	fe843783          	ld	a5,-24(s0)
    80201f0a:	0007bc23          	sd	zero,24(a5)
    p->size = 0;
    80201f0e:	fe843783          	ld	a5,-24(s0)
    80201f12:	5807b423          	sd	zero,1416(a5)
    p->pid = 0;
    80201f16:	fe843783          	ld	a5,-24(s0)
    80201f1a:	0007a623          	sw	zero,12(a5)
    p->parent = 0;
    80201f1e:	fe843783          	ld	a5,-24(s0)
    80201f22:	5807b023          	sd	zero,1408(a5)
    p->chan = NULL;
    80201f26:	fe843783          	ld	a5,-24(s0)
    80201f2a:	0007b823          	sd	zero,16(a5)
    p->xstatus = 0;
    80201f2e:	fe843783          	ld	a5,-24(s0)
    80201f32:	0007a423          	sw	zero,8(a5)
    p->heap = NULL;
    80201f36:	fe843783          	ld	a5,-24(s0)
    80201f3a:	5807bc23          	sd	zero,1432(a5)
    p->state = UNUSED;
    80201f3e:	fe843783          	ld	a5,-24(s0)
    80201f42:	0007a023          	sw	zero,0(a5)
}
    80201f46:	0001                	nop
    80201f48:	60e2                	ld	ra,24(sp)
    80201f4a:	6442                	ld	s0,16(sp)
    80201f4c:	6105                	addi	sp,sp,32
    80201f4e:	8082                	ret

0000000080201f50 <creat_proc>:

void
creat_proc(char* path) {
    80201f50:	7139                	addi	sp,sp,-64
    80201f52:	fc06                	sd	ra,56(sp)
    80201f54:	f822                	sd	s0,48(sp)
    80201f56:	0080                	addi	s0,sp,64
    80201f58:	fca43423          	sd	a0,-56(s0)
    if (path == NULL) {
    80201f5c:	fc843783          	ld	a5,-56(s0)
    80201f60:	eb91                	bnez	a5,80201f74 <creat_proc+0x24>
        printf("execute over\n");
    80201f62:	00009517          	auipc	a0,0x9
    80201f66:	32650513          	addi	a0,a0,806 # 8020b288 <etext+0x288>
    80201f6a:	00001097          	auipc	ra,0x1
    80201f6e:	988080e7          	jalr	-1656(ra) # 802028f2 <printf>
        while (1)
    80201f72:	a001                	j	80201f72 <creat_proc+0x22>
            ;
    }
    runOver = FALSE;
    80201f74:	0000b797          	auipc	a5,0xb
    80201f78:	a3c78793          	addi	a5,a5,-1476 # 8020c9b0 <runOver>
    80201f7c:	0007a023          	sw	zero,0(a5)
    proc_t* p = alloc_proc();
    80201f80:	00000097          	auipc	ra,0x0
    80201f84:	d6a080e7          	jalr	-662(ra) # 80201cea <alloc_proc>
    80201f88:	fea43023          	sd	a0,-32(s0)
    for (int i = 0; i < PRO_SIZE; i += PAGE_SIZE) {
    80201f8c:	fe042623          	sw	zero,-20(s0)
    80201f90:	a08d                	j	80201ff2 <creat_proc+0xa2>
        void* mem = kalloc();
    80201f92:	ffffe097          	auipc	ra,0xffffe
    80201f96:	7e2080e7          	jalr	2018(ra) # 80200774 <kalloc>
    80201f9a:	fca43823          	sd	a0,-48(s0)
        memset(mem, 0, PAGE_SIZE);
    80201f9e:	6605                	lui	a2,0x1
    80201fa0:	4581                	li	a1,0
    80201fa2:	fd043503          	ld	a0,-48(s0)
    80201fa6:	00001097          	auipc	ra,0x1
    80201faa:	b80080e7          	jalr	-1152(ra) # 80202b26 <memset>
        create_pages_map(p->upageTable, i, (address_t)mem, PAGE_SIZE, PTE_R | PTE_W | PTE_X | PTE_U);
    80201fae:	fe043783          	ld	a5,-32(s0)
    80201fb2:	6f9c                	ld	a5,24(a5)
    80201fb4:	fec42583          	lw	a1,-20(s0)
    80201fb8:	fd043603          	ld	a2,-48(s0)
    80201fbc:	4779                	li	a4,30
    80201fbe:	6685                	lui	a3,0x1
    80201fc0:	853e                	mv	a0,a5
    80201fc2:	fffff097          	auipc	ra,0xfffff
    80201fc6:	9d6080e7          	jalr	-1578(ra) # 80200998 <create_pages_map>
        create_pages_map(p->kpageTable, i, (address_t)mem, PAGE_SIZE, PTE_R | PTE_W | PTE_X);
    80201fca:	fe043783          	ld	a5,-32(s0)
    80201fce:	739c                	ld	a5,32(a5)
    80201fd0:	fec42583          	lw	a1,-20(s0)
    80201fd4:	fd043603          	ld	a2,-48(s0)
    80201fd8:	4739                	li	a4,14
    80201fda:	6685                	lui	a3,0x1
    80201fdc:	853e                	mv	a0,a5
    80201fde:	fffff097          	auipc	ra,0xfffff
    80201fe2:	9ba080e7          	jalr	-1606(ra) # 80200998 <create_pages_map>
    for (int i = 0; i < PRO_SIZE; i += PAGE_SIZE) {
    80201fe6:	fec42703          	lw	a4,-20(s0)
    80201fea:	6785                	lui	a5,0x1
    80201fec:	9fb9                	addw	a5,a5,a4
    80201fee:	fef42623          	sw	a5,-20(s0)
    80201ff2:	fec42783          	lw	a5,-20(s0)
    80201ff6:	0007871b          	sext.w	a4,a5
    80201ffa:	6795                	lui	a5,0x5
    80201ffc:	f8f74be3          	blt	a4,a5,80201f92 <creat_proc+0x42>
    }
    void* stack_mem = kalloc();
    80202000:	ffffe097          	auipc	ra,0xffffe
    80202004:	774080e7          	jalr	1908(ra) # 80200774 <kalloc>
    80202008:	fca43c23          	sd	a0,-40(s0)
    memset(stack_mem, 0, PAGE_SIZE);
    8020200c:	6605                	lui	a2,0x1
    8020200e:	4581                	li	a1,0
    80202010:	fd843503          	ld	a0,-40(s0)
    80202014:	00001097          	auipc	ra,0x1
    80202018:	b12080e7          	jalr	-1262(ra) # 80202b26 <memset>
    create_pages_map(p->upageTable, (address_t)PRO_SIZE, (address_t)stack_mem, PAGE_SIZE, PTE_R | PTE_W | PTE_U);
    8020201c:	fe043783          	ld	a5,-32(s0)
    80202020:	6f9c                	ld	a5,24(a5)
    80202022:	fd843603          	ld	a2,-40(s0)
    80202026:	4759                	li	a4,22
    80202028:	6685                	lui	a3,0x1
    8020202a:	6595                	lui	a1,0x5
    8020202c:	853e                	mv	a0,a5
    8020202e:	fffff097          	auipc	ra,0xfffff
    80202032:	96a080e7          	jalr	-1686(ra) # 80200998 <create_pages_map>
    p->size = PRO_SIZE + PAGE_SIZE;
    80202036:	fe043783          	ld	a5,-32(s0)
    8020203a:	6719                	lui	a4,0x6
    8020203c:	58e7b423          	sd	a4,1416(a5) # 5588 <_entry-0x801faa78>
    //  elf_load(p, path);
    p->path = path;
    80202040:	fe043783          	ld	a5,-32(s0)
    80202044:	fc843703          	ld	a4,-56(s0)
    80202048:	5ce7b823          	sd	a4,1488(a5)
    p->trapFrame->sp = p->size;
    8020204c:	fe043783          	ld	a5,-32(s0)
    80202050:	779c                	ld	a5,40(a5)
    80202052:	fe043703          	ld	a4,-32(s0)
    80202056:	58873703          	ld	a4,1416(a4) # 6588 <_entry-0x801f9a78>
    8020205a:	fb98                	sd	a4,48(a5)
    p->state = READY;
    8020205c:	fe043783          	ld	a5,-32(s0)
    80202060:	4709                	li	a4,2
    80202062:	c398                	sw	a4,0(a5)
}
    80202064:	0001                	nop
    80202066:	70e2                	ld	ra,56(sp)
    80202068:	7442                	ld	s0,48(sp)
    8020206a:	6121                	addi	sp,sp,64
    8020206c:	8082                	ret

000000008020206e <scheduler>:

void
scheduler(void) {
    8020206e:	7139                	addi	sp,sp,-64
    80202070:	fc06                	sd	ra,56(sp)
    80202072:	f822                	sd	s0,48(sp)
    80202074:	0080                	addi	s0,sp,64
    proc_t* p;
    extern pageTable_t kernel_pagetable;
    cpu_t* c = getCurrentCPU();
    80202076:	00000097          	auipc	ra,0x0
    8020207a:	1b8080e7          	jalr	440(ra) # 8020222e <getCurrentCPU>
    8020207e:	fca43c23          	sd	a0,-40(s0)
    uint32_t isFind = 0;
    80202082:	fe042223          	sw	zero,-28(s0)
    char* argv[] = {"dup", NULL};
    80202086:	00009797          	auipc	a5,0x9
    8020208a:	21278793          	addi	a5,a5,530 # 8020b298 <etext+0x298>
    8020208e:	fcf43023          	sd	a5,-64(s0)
    80202092:	fc043423          	sd	zero,-56(s0)
    int i = 0;
    80202096:	fe042023          	sw	zero,-32(s0)

    while (1) {
        isFind = 0;
    8020209a:	fe042223          	sw	zero,-28(s0)
        intr_on();
    8020209e:	00002097          	auipc	ra,0x2
    802020a2:	c7e080e7          	jalr	-898(ra) # 80203d1c <intr_on>
        for (p = proc; p < &proc[NPROC]; p++) {
    802020a6:	00013797          	auipc	a5,0x13
    802020aa:	04278793          	addi	a5,a5,66 # 802150e8 <proc>
    802020ae:	fef43423          	sd	a5,-24(s0)
    802020b2:	aa05                	j	802021e2 <scheduler+0x174>
            spinlock_acquire(&p->lk);
    802020b4:	fe843783          	ld	a5,-24(s0)
    802020b8:	56878793          	addi	a5,a5,1384
    802020bc:	853e                	mv	a0,a5
    802020be:	00003097          	auipc	ra,0x3
    802020c2:	894080e7          	jalr	-1900(ra) # 80204952 <spinlock_acquire>
            if (p->state == READY) {
    802020c6:	fe843783          	ld	a5,-24(s0)
    802020ca:	439c                	lw	a5,0(a5)
    802020cc:	873e                	mv	a4,a5
    802020ce:	4789                	li	a5,2
    802020d0:	0cf71f63          	bne	a4,a5,802021ae <scheduler+0x140>
                isFind = 1;
    802020d4:	4785                	li	a5,1
    802020d6:	fef42223          	sw	a5,-28(s0)
                p->state = RUNNING;
    802020da:	fe843783          	ld	a5,-24(s0)
    802020de:	470d                	li	a4,3
    802020e0:	c398                	sw	a4,0(a5)
                // spinlock_release(&p->lk);
                getCurrentCPU()->current_p = p;
    802020e2:	00000097          	auipc	ra,0x0
    802020e6:	14c080e7          	jalr	332(ra) # 8020222e <getCurrentCPU>
    802020ea:	872a                	mv	a4,a0
    802020ec:	fe843783          	ld	a5,-24(s0)
    802020f0:	fb3c                	sd	a5,112(a4)
                p->tms.entry_kernel = r_time();
    802020f2:	00000097          	auipc	ra,0x0
    802020f6:	a1c080e7          	jalr	-1508(ra) # 80201b0e <r_time>
    802020fa:	872a                	mv	a4,a0
    802020fc:	fe843783          	ld	a5,-24(s0)
    80202100:	5ce7b023          	sd	a4,1472(a5)
                w_satp(PAGE_TABLE_SHIFT(p->kpageTable));
    80202104:	fe843783          	ld	a5,-24(s0)
    80202108:	739c                	ld	a5,32(a5)
    8020210a:	00c7d713          	srli	a4,a5,0xc
    8020210e:	57fd                	li	a5,-1
    80202110:	17fe                	slli	a5,a5,0x3f
    80202112:	8fd9                	or	a5,a5,a4
    80202114:	853e                	mv	a0,a5
    80202116:	00000097          	auipc	ra,0x0
    8020211a:	9cc080e7          	jalr	-1588(ra) # 80201ae2 <w_satp>
                sfenve_vma();
    8020211e:	00000097          	auipc	ra,0x0
    80202122:	9de080e7          	jalr	-1570(ra) # 80201afc <sfenve_vma>
                contentSwitch(&(c->context), &(p->context));
    80202126:	fd843703          	ld	a4,-40(s0)
    8020212a:	fe843783          	ld	a5,-24(s0)
    8020212e:	03078793          	addi	a5,a5,48
    80202132:	85be                	mv	a1,a5
    80202134:	853a                	mv	a0,a4
    80202136:	ffffe097          	auipc	ra,0xffffe
    8020213a:	ee4080e7          	jalr	-284(ra) # 8020001a <contentSwitch>
                w_satp(PAGE_TABLE_SHIFT(kernel_pagetable));
    8020213e:	00013797          	auipc	a5,0x13
    80202142:	fa278793          	addi	a5,a5,-94 # 802150e0 <kernel_pagetable>
    80202146:	639c                	ld	a5,0(a5)
    80202148:	00c7d713          	srli	a4,a5,0xc
    8020214c:	57fd                	li	a5,-1
    8020214e:	17fe                	slli	a5,a5,0x3f
    80202150:	8fd9                	or	a5,a5,a4
    80202152:	853e                	mv	a0,a5
    80202154:	00000097          	auipc	ra,0x0
    80202158:	98e080e7          	jalr	-1650(ra) # 80201ae2 <w_satp>
                sfenve_vma();
    8020215c:	00000097          	auipc	ra,0x0
    80202160:	9a0080e7          	jalr	-1632(ra) # 80201afc <sfenve_vma>
                p = proc;
    80202164:	00013797          	auipc	a5,0x13
    80202168:	f8478793          	addi	a5,a5,-124 # 802150e8 <proc>
    8020216c:	fef43423          	sd	a5,-24(s0)
                proc_t* nowp = getCurrentProc();
    80202170:	00000097          	auipc	ra,0x0
    80202174:	a5e080e7          	jalr	-1442(ra) # 80201bce <getCurrentProc>
    80202178:	fca43823          	sd	a0,-48(s0)
                if ((nowp->state == ZOMBIE) && (nowp->isForked == 0))
    8020217c:	fd043783          	ld	a5,-48(s0)
    80202180:	439c                	lw	a5,0(a5)
    80202182:	873e                	mv	a4,a5
    80202184:	4795                	li	a5,5
    80202186:	00f71d63          	bne	a4,a5,802021a0 <scheduler+0x132>
    8020218a:	fd043783          	ld	a5,-48(s0)
    8020218e:	5907d783          	lhu	a5,1424(a5)
    80202192:	e799                	bnez	a5,802021a0 <scheduler+0x132>
                    freeproc(nowp);
    80202194:	fd043503          	ld	a0,-48(s0)
    80202198:	00000097          	auipc	ra,0x0
    8020219c:	d0e080e7          	jalr	-754(ra) # 80201ea6 <freeproc>
                // isFind = 0;  // TODO?
                getCurrentCPU()->current_p = NULL;
    802021a0:	00000097          	auipc	ra,0x0
    802021a4:	08e080e7          	jalr	142(ra) # 8020222e <getCurrentCPU>
    802021a8:	87aa                	mv	a5,a0
    802021aa:	0607b823          	sd	zero,112(a5)
            }
            if (spinlock_isHold(&p->lk))
    802021ae:	fe843783          	ld	a5,-24(s0)
    802021b2:	56878793          	addi	a5,a5,1384
    802021b6:	853e                	mv	a0,a5
    802021b8:	00002097          	auipc	ra,0x2
    802021bc:	72c080e7          	jalr	1836(ra) # 802048e4 <spinlock_isHold>
    802021c0:	87aa                	mv	a5,a0
    802021c2:	cb91                	beqz	a5,802021d6 <scheduler+0x168>
                spinlock_release(&p->lk);
    802021c4:	fe843783          	ld	a5,-24(s0)
    802021c8:	56878793          	addi	a5,a5,1384
    802021cc:	853e                	mv	a0,a5
    802021ce:	00002097          	auipc	ra,0x2
    802021d2:	7fa080e7          	jalr	2042(ra) # 802049c8 <spinlock_release>
        for (p = proc; p < &proc[NPROC]; p++) {
    802021d6:	fe843783          	ld	a5,-24(s0)
    802021da:	5d878793          	addi	a5,a5,1496
    802021de:	fef43423          	sd	a5,-24(s0)
    802021e2:	fe843703          	ld	a4,-24(s0)
    802021e6:	00025797          	auipc	a5,0x25
    802021ea:	33278793          	addi	a5,a5,818 # 80227518 <cpu>
    802021ee:	ecf763e3          	bltu	a4,a5,802020b4 <scheduler+0x46>
        }
        if (isFind == 0 && runOver) {
    802021f2:	fe442783          	lw	a5,-28(s0)
    802021f6:	2781                	sext.w	a5,a5
    802021f8:	ea0791e3          	bnez	a5,8020209a <scheduler+0x2c>
    802021fc:	0000a797          	auipc	a5,0xa
    80202200:	7b478793          	addi	a5,a5,1972 # 8020c9b0 <runOver>
    80202204:	439c                	lw	a5,0(a5)
    80202206:	e8078ae3          	beqz	a5,8020209a <scheduler+0x2c>
            creat_proc(argv[i++]);
    8020220a:	fe042783          	lw	a5,-32(s0)
    8020220e:	0017871b          	addiw	a4,a5,1
    80202212:	fee42023          	sw	a4,-32(s0)
    80202216:	078e                	slli	a5,a5,0x3
    80202218:	ff040713          	addi	a4,s0,-16
    8020221c:	97ba                	add	a5,a5,a4
    8020221e:	fd07b783          	ld	a5,-48(a5)
    80202222:	853e                	mv	a0,a5
    80202224:	00000097          	auipc	ra,0x0
    80202228:	d2c080e7          	jalr	-724(ra) # 80201f50 <creat_proc>
        isFind = 0;
    8020222c:	b5bd                	j	8020209a <scheduler+0x2c>

000000008020222e <getCurrentCPU>:
    while (1)
        ;
}

cpu_t*
getCurrentCPU(void) {
    8020222e:	1141                	addi	sp,sp,-16
    80202230:	e406                	sd	ra,8(sp)
    80202232:	e022                	sd	s0,0(sp)
    80202234:	0800                	addi	s0,sp,16
    return &cpu[r_tp()];
    80202236:	00000097          	auipc	ra,0x0
    8020223a:	894080e7          	jalr	-1900(ra) # 80201aca <r_tp>
    8020223e:	87aa                	mv	a5,a0
    80202240:	00779713          	slli	a4,a5,0x7
    80202244:	00025797          	auipc	a5,0x25
    80202248:	2d478793          	addi	a5,a5,724 # 80227518 <cpu>
    8020224c:	97ba                	add	a5,a5,a4
}
    8020224e:	853e                	mv	a0,a5
    80202250:	60a2                	ld	ra,8(sp)
    80202252:	6402                	ld	s0,0(sp)
    80202254:	0141                	addi	sp,sp,16
    80202256:	8082                	ret

0000000080202258 <yield>:

void
yield(void) {
    80202258:	1101                	addi	sp,sp,-32
    8020225a:	ec06                	sd	ra,24(sp)
    8020225c:	e822                	sd	s0,16(sp)
    8020225e:	1000                	addi	s0,sp,32
#ifdef DEBUG
    printf("yield");
    80202260:	00009517          	auipc	a0,0x9
    80202264:	04050513          	addi	a0,a0,64 # 8020b2a0 <etext+0x2a0>
    80202268:	00000097          	auipc	ra,0x0
    8020226c:	68a080e7          	jalr	1674(ra) # 802028f2 <printf>
#endif
    proc_t* p = getCurrentProc();
    80202270:	00000097          	auipc	ra,0x0
    80202274:	95e080e7          	jalr	-1698(ra) # 80201bce <getCurrentProc>
    80202278:	fea43423          	sd	a0,-24(s0)
    spinlock_acquire(&p->lk);
    8020227c:	fe843783          	ld	a5,-24(s0)
    80202280:	56878793          	addi	a5,a5,1384
    80202284:	853e                	mv	a0,a5
    80202286:	00002097          	auipc	ra,0x2
    8020228a:	6cc080e7          	jalr	1740(ra) # 80204952 <spinlock_acquire>
    p->state = READY;
    8020228e:	fe843783          	ld	a5,-24(s0)
    80202292:	4709                	li	a4,2
    80202294:	c398                	sw	a4,0(a5)
    sched();
    80202296:	00000097          	auipc	ra,0x0
    8020229a:	024080e7          	jalr	36(ra) # 802022ba <sched>
    spinlock_release(&p->lk);
    8020229e:	fe843783          	ld	a5,-24(s0)
    802022a2:	56878793          	addi	a5,a5,1384
    802022a6:	853e                	mv	a0,a5
    802022a8:	00002097          	auipc	ra,0x2
    802022ac:	720080e7          	jalr	1824(ra) # 802049c8 <spinlock_release>
}
    802022b0:	0001                	nop
    802022b2:	60e2                	ld	ra,24(sp)
    802022b4:	6442                	ld	s0,16(sp)
    802022b6:	6105                	addi	sp,sp,32
    802022b8:	8082                	ret

00000000802022ba <sched>:

void
sched(void) {
    802022ba:	7179                	addi	sp,sp,-48
    802022bc:	f406                	sd	ra,40(sp)
    802022be:	f022                	sd	s0,32(sp)
    802022c0:	ec26                	sd	s1,24(sp)
    802022c2:	1800                	addi	s0,sp,48
    proc_t* p = getCurrentProc();
    802022c4:	00000097          	auipc	ra,0x0
    802022c8:	90a080e7          	jalr	-1782(ra) # 80201bce <getCurrentProc>
    802022cc:	fca43c23          	sd	a0,-40(s0)
    contentSwitch(&p->context, &getCurrentCPU()->context);
    802022d0:	fd843783          	ld	a5,-40(s0)
    802022d4:	03078493          	addi	s1,a5,48
    802022d8:	00000097          	auipc	ra,0x0
    802022dc:	f56080e7          	jalr	-170(ra) # 8020222e <getCurrentCPU>
    802022e0:	87aa                	mv	a5,a0
    802022e2:	85be                	mv	a1,a5
    802022e4:	8526                	mv	a0,s1
    802022e6:	ffffe097          	auipc	ra,0xffffe
    802022ea:	d34080e7          	jalr	-716(ra) # 8020001a <contentSwitch>
}
    802022ee:	0001                	nop
    802022f0:	70a2                	ld	ra,40(sp)
    802022f2:	7402                	ld	s0,32(sp)
    802022f4:	64e2                	ld	s1,24(sp)
    802022f6:	6145                	addi	sp,sp,48
    802022f8:	8082                	ret

00000000802022fa <sleep_spin>:
//         semaphore_acquire(lk);
//     }
// }

void
sleep_spin(void* chan, spinlock_t* lk) {
    802022fa:	7179                	addi	sp,sp,-48
    802022fc:	f406                	sd	ra,40(sp)
    802022fe:	f022                	sd	s0,32(sp)
    80202300:	1800                	addi	s0,sp,48
    80202302:	fca43c23          	sd	a0,-40(s0)
    80202306:	fcb43823          	sd	a1,-48(s0)
    proc_t* p = getCurrentProc();
    8020230a:	00000097          	auipc	ra,0x0
    8020230e:	8c4080e7          	jalr	-1852(ra) # 80201bce <getCurrentProc>
    80202312:	fea43423          	sd	a0,-24(s0)
    if (lk != &p->lk) {
    80202316:	fe843783          	ld	a5,-24(s0)
    8020231a:	56878793          	addi	a5,a5,1384
    8020231e:	fd043703          	ld	a4,-48(s0)
    80202322:	02f70263          	beq	a4,a5,80202346 <sleep_spin+0x4c>
        spinlock_acquire(&p->lk);
    80202326:	fe843783          	ld	a5,-24(s0)
    8020232a:	56878793          	addi	a5,a5,1384
    8020232e:	853e                	mv	a0,a5
    80202330:	00002097          	auipc	ra,0x2
    80202334:	622080e7          	jalr	1570(ra) # 80204952 <spinlock_acquire>
        spinlock_release(lk);
    80202338:	fd043503          	ld	a0,-48(s0)
    8020233c:	00002097          	auipc	ra,0x2
    80202340:	68c080e7          	jalr	1676(ra) # 802049c8 <spinlock_release>
    80202344:	a811                	j	80202358 <sleep_spin+0x5e>
    } else
        spinlock_release(&p->lk);
    80202346:	fe843783          	ld	a5,-24(s0)
    8020234a:	56878793          	addi	a5,a5,1384
    8020234e:	853e                	mv	a0,a5
    80202350:	00002097          	auipc	ra,0x2
    80202354:	678080e7          	jalr	1656(ra) # 802049c8 <spinlock_release>

    p->chan = chan;
    80202358:	fe843783          	ld	a5,-24(s0)
    8020235c:	fd843703          	ld	a4,-40(s0)
    80202360:	eb98                	sd	a4,16(a5)
    p->state = SLEEPING;
    80202362:	fe843783          	ld	a5,-24(s0)
    80202366:	4711                	li	a4,4
    80202368:	c398                	sw	a4,0(a5)

    sched();
    8020236a:	00000097          	auipc	ra,0x0
    8020236e:	f50080e7          	jalr	-176(ra) # 802022ba <sched>

    p->chan = 0;
    80202372:	fe843783          	ld	a5,-24(s0)
    80202376:	0007b823          	sd	zero,16(a5)

    if (lk != &p->lk) {
    8020237a:	fe843783          	ld	a5,-24(s0)
    8020237e:	56878793          	addi	a5,a5,1384
    80202382:	fd043703          	ld	a4,-48(s0)
    80202386:	02f70163          	beq	a4,a5,802023a8 <sleep_spin+0xae>
        spinlock_release(&p->lk);
    8020238a:	fe843783          	ld	a5,-24(s0)
    8020238e:	56878793          	addi	a5,a5,1384
    80202392:	853e                	mv	a0,a5
    80202394:	00002097          	auipc	ra,0x2
    80202398:	634080e7          	jalr	1588(ra) # 802049c8 <spinlock_release>
        spinlock_acquire(lk);
    8020239c:	fd043503          	ld	a0,-48(s0)
    802023a0:	00002097          	auipc	ra,0x2
    802023a4:	5b2080e7          	jalr	1458(ra) # 80204952 <spinlock_acquire>
    }
}
    802023a8:	0001                	nop
    802023aa:	70a2                	ld	ra,40(sp)
    802023ac:	7402                	ld	s0,32(sp)
    802023ae:	6145                	addi	sp,sp,48
    802023b0:	8082                	ret

00000000802023b2 <proc_wakeupSpin>:
//         semaphore_release(&p->lk);
//     }
// }

void
proc_wakeupSpin(void* chan) {
    802023b2:	7179                	addi	sp,sp,-48
    802023b4:	f406                	sd	ra,40(sp)
    802023b6:	f022                	sd	s0,32(sp)
    802023b8:	1800                	addi	s0,sp,48
    802023ba:	fca43c23          	sd	a0,-40(s0)
    proc_t* p;
    for (p = proc; p < &proc[NPROC]; p++) {
    802023be:	00013797          	auipc	a5,0x13
    802023c2:	d2a78793          	addi	a5,a5,-726 # 802150e8 <proc>
    802023c6:	fef43423          	sd	a5,-24(s0)
    802023ca:	a899                	j	80202420 <proc_wakeupSpin+0x6e>
        spinlock_acquire(&p->lk);
    802023cc:	fe843783          	ld	a5,-24(s0)
    802023d0:	56878793          	addi	a5,a5,1384
    802023d4:	853e                	mv	a0,a5
    802023d6:	00002097          	auipc	ra,0x2
    802023da:	57c080e7          	jalr	1404(ra) # 80204952 <spinlock_acquire>
        if (p->state == SLEEPING && p->chan == chan) {
    802023de:	fe843783          	ld	a5,-24(s0)
    802023e2:	439c                	lw	a5,0(a5)
    802023e4:	873e                	mv	a4,a5
    802023e6:	4791                	li	a5,4
    802023e8:	00f71d63          	bne	a4,a5,80202402 <proc_wakeupSpin+0x50>
    802023ec:	fe843783          	ld	a5,-24(s0)
    802023f0:	6b9c                	ld	a5,16(a5)
    802023f2:	fd843703          	ld	a4,-40(s0)
    802023f6:	00f71663          	bne	a4,a5,80202402 <proc_wakeupSpin+0x50>
            p->state = READY;
    802023fa:	fe843783          	ld	a5,-24(s0)
    802023fe:	4709                	li	a4,2
    80202400:	c398                	sw	a4,0(a5)
        }
        spinlock_release(&p->lk);
    80202402:	fe843783          	ld	a5,-24(s0)
    80202406:	56878793          	addi	a5,a5,1384
    8020240a:	853e                	mv	a0,a5
    8020240c:	00002097          	auipc	ra,0x2
    80202410:	5bc080e7          	jalr	1468(ra) # 802049c8 <spinlock_release>
    for (p = proc; p < &proc[NPROC]; p++) {
    80202414:	fe843783          	ld	a5,-24(s0)
    80202418:	5d878793          	addi	a5,a5,1496
    8020241c:	fef43423          	sd	a5,-24(s0)
    80202420:	fe843703          	ld	a4,-24(s0)
    80202424:	00025797          	auipc	a5,0x25
    80202428:	0f478793          	addi	a5,a5,244 # 80227518 <cpu>
    8020242c:	faf760e3          	bltu	a4,a5,802023cc <proc_wakeupSpin+0x1a>
    }
}
    80202430:	0001                	nop
    80202432:	0001                	nop
    80202434:	70a2                	ld	ra,40(sp)
    80202436:	7402                	ld	s0,32(sp)
    80202438:	6145                	addi	sp,sp,48
    8020243a:	8082                	ret

000000008020243c <proc_wakeup>:

void
proc_wakeup(proc_t* w_proc) {
    8020243c:	1101                	addi	sp,sp,-32
    8020243e:	ec06                	sd	ra,24(sp)
    80202440:	e822                	sd	s0,16(sp)
    80202442:	1000                	addi	s0,sp,32
    80202444:	fea43423          	sd	a0,-24(s0)
    if ((w_proc >= proc) && (w_proc < &proc[NPROC]) && (w_proc->state == SLEEPING)) {
    80202448:	fe843703          	ld	a4,-24(s0)
    8020244c:	00013797          	auipc	a5,0x13
    80202450:	c9c78793          	addi	a5,a5,-868 # 802150e8 <proc>
    80202454:	02f76663          	bltu	a4,a5,80202480 <proc_wakeup+0x44>
    80202458:	fe843703          	ld	a4,-24(s0)
    8020245c:	00025797          	auipc	a5,0x25
    80202460:	0bc78793          	addi	a5,a5,188 # 80227518 <cpu>
    80202464:	00f77e63          	bgeu	a4,a5,80202480 <proc_wakeup+0x44>
    80202468:	fe843783          	ld	a5,-24(s0)
    8020246c:	439c                	lw	a5,0(a5)
    8020246e:	873e                	mv	a4,a5
    80202470:	4791                	li	a5,4
    80202472:	00f71763          	bne	a4,a5,80202480 <proc_wakeup+0x44>
        w_proc->state = READY;
    80202476:	fe843783          	ld	a5,-24(s0)
    8020247a:	4709                	li	a4,2
    8020247c:	c398                	sw	a4,0(a5)
    } else {
        panic("proc wakeup : unknown proc\n");
        while (1)
            ;
    }
}
    8020247e:	a811                	j	80202492 <proc_wakeup+0x56>
        panic("proc wakeup : unknown proc\n");
    80202480:	00009517          	auipc	a0,0x9
    80202484:	e2850513          	addi	a0,a0,-472 # 8020b2a8 <etext+0x2a8>
    80202488:	00000097          	auipc	ra,0x0
    8020248c:	67c080e7          	jalr	1660(ra) # 80202b04 <panic>
        while (1)
    80202490:	a001                	j	80202490 <proc_wakeup+0x54>
}
    80202492:	60e2                	ld	ra,24(sp)
    80202494:	6442                	ld	s0,16(sp)
    80202496:	6105                	addi	sp,sp,32
    80202498:	8082                	ret

000000008020249a <wait>:

pid_t
wait(pid_t pid) {
    8020249a:	715d                	addi	sp,sp,-80
    8020249c:	e486                	sd	ra,72(sp)
    8020249e:	e0a2                	sd	s0,64(sp)
    802024a0:	0880                	addi	s0,sp,80
    802024a2:	87aa                	mv	a5,a0
    802024a4:	faf42e23          	sw	a5,-68(s0)
    proc_t* p = getCurrentProc();
    802024a8:	fffff097          	auipc	ra,0xfffff
    802024ac:	726080e7          	jalr	1830(ra) # 80201bce <getCurrentProc>
    802024b0:	fca43823          	sd	a0,-48(s0)
    spinlock_acquire(&p->lk);
    802024b4:	fd043783          	ld	a5,-48(s0)
    802024b8:	56878793          	addi	a5,a5,1384
    802024bc:	853e                	mv	a0,a5
    802024be:	00002097          	auipc	ra,0x2
    802024c2:	494080e7          	jalr	1172(ra) # 80204952 <spinlock_acquire>
    int havekids = 0;
    802024c6:	fe042623          	sw	zero,-20(s0)
    if (pid == -1) {
    802024ca:	fbc42783          	lw	a5,-68(s0)
    802024ce:	0007871b          	sext.w	a4,a5
    802024d2:	57fd                	li	a5,-1
    802024d4:	0cf71d63          	bne	a4,a5,802025ae <wait+0x114>
        while (1) {
            for (proc_t* child_p = proc; child_p < &proc[NPROC]; child_p++) {
    802024d8:	00013797          	auipc	a5,0x13
    802024dc:	c1078793          	addi	a5,a5,-1008 # 802150e8 <proc>
    802024e0:	fef43023          	sd	a5,-32(s0)
    802024e4:	a059                	j	8020256a <wait+0xd0>
                if (child_p->parent == p) {
    802024e6:	fe043783          	ld	a5,-32(s0)
    802024ea:	5807b783          	ld	a5,1408(a5)
    802024ee:	fd043703          	ld	a4,-48(s0)
    802024f2:	06f71663          	bne	a4,a5,8020255e <wait+0xc4>
                    havekids = 1;
    802024f6:	4785                	li	a5,1
    802024f8:	fef42623          	sw	a5,-20(s0)
                    spinlock_acquire(&child_p->lk);
    802024fc:	fe043783          	ld	a5,-32(s0)
    80202500:	56878793          	addi	a5,a5,1384
    80202504:	853e                	mv	a0,a5
    80202506:	00002097          	auipc	ra,0x2
    8020250a:	44c080e7          	jalr	1100(ra) # 80204952 <spinlock_acquire>
                    if (child_p->state == ZOMBIE) {
    8020250e:	fe043783          	ld	a5,-32(s0)
    80202512:	439c                	lw	a5,0(a5)
    80202514:	873e                	mv	a4,a5
    80202516:	4795                	li	a5,5
    80202518:	02f71a63          	bne	a4,a5,8020254c <wait+0xb2>
                        freeproc(child_p);
    8020251c:	fe043503          	ld	a0,-32(s0)
    80202520:	00000097          	auipc	ra,0x0
    80202524:	986080e7          	jalr	-1658(ra) # 80201ea6 <freeproc>
                        spinlock_release(&child_p->lk);
    80202528:	fe043783          	ld	a5,-32(s0)
    8020252c:	56878793          	addi	a5,a5,1384
    80202530:	853e                	mv	a0,a5
    80202532:	00002097          	auipc	ra,0x2
    80202536:	496080e7          	jalr	1174(ra) # 802049c8 <spinlock_release>
                        spinlock_release(&p->lk);
    8020253a:	fd043783          	ld	a5,-48(s0)
    8020253e:	56878793          	addi	a5,a5,1384
    80202542:	853e                	mv	a0,a5
    80202544:	00002097          	auipc	ra,0x2
    80202548:	484080e7          	jalr	1156(ra) # 802049c8 <spinlock_release>
                    }
                    spinlock_release(&child_p->lk);
    8020254c:	fe043783          	ld	a5,-32(s0)
    80202550:	56878793          	addi	a5,a5,1384
    80202554:	853e                	mv	a0,a5
    80202556:	00002097          	auipc	ra,0x2
    8020255a:	472080e7          	jalr	1138(ra) # 802049c8 <spinlock_release>
            for (proc_t* child_p = proc; child_p < &proc[NPROC]; child_p++) {
    8020255e:	fe043783          	ld	a5,-32(s0)
    80202562:	5d878793          	addi	a5,a5,1496
    80202566:	fef43023          	sd	a5,-32(s0)
    8020256a:	fe043703          	ld	a4,-32(s0)
    8020256e:	00025797          	auipc	a5,0x25
    80202572:	faa78793          	addi	a5,a5,-86 # 80227518 <cpu>
    80202576:	f6f768e3          	bltu	a4,a5,802024e6 <wait+0x4c>
                }
            }
            if (!havekids) {
    8020257a:	fec42783          	lw	a5,-20(s0)
    8020257e:	2781                	sext.w	a5,a5
    80202580:	eb99                	bnez	a5,80202596 <wait+0xfc>
                spinlock_release(&p->lk);
    80202582:	fd043783          	ld	a5,-48(s0)
    80202586:	56878793          	addi	a5,a5,1384
    8020258a:	853e                	mv	a0,a5
    8020258c:	00002097          	auipc	ra,0x2
    80202590:	43c080e7          	jalr	1084(ra) # 802049c8 <spinlock_release>
    80202594:	b791                	j	802024d8 <wait+0x3e>
            } else {
                sleep_spin(p, &p->lk);
    80202596:	fd043783          	ld	a5,-48(s0)
    8020259a:	56878793          	addi	a5,a5,1384
    8020259e:	85be                	mv	a1,a5
    802025a0:	fd043503          	ld	a0,-48(s0)
    802025a4:	00000097          	auipc	ra,0x0
    802025a8:	d56080e7          	jalr	-682(ra) # 802022fa <sleep_spin>
            for (proc_t* child_p = proc; child_p < &proc[NPROC]; child_p++) {
    802025ac:	b735                	j	802024d8 <wait+0x3e>
            }
        }
    } else {
        while (1) {
            for (proc_t* np = proc; np < &proc[NPROC]; np++) {
    802025ae:	00013797          	auipc	a5,0x13
    802025b2:	b3a78793          	addi	a5,a5,-1222 # 802150e8 <proc>
    802025b6:	fcf43c23          	sd	a5,-40(s0)
    802025ba:	a861                	j	80202652 <wait+0x1b8>
                if (np->pid == pid) {
    802025bc:	fd843783          	ld	a5,-40(s0)
    802025c0:	47d8                	lw	a4,12(a5)
    802025c2:	fbc42783          	lw	a5,-68(s0)
    802025c6:	2781                	sext.w	a5,a5
    802025c8:	06e79f63          	bne	a5,a4,80202646 <wait+0x1ac>
                    havekids = 1;
    802025cc:	4785                	li	a5,1
    802025ce:	fef42623          	sw	a5,-20(s0)
                    spinlock_acquire(&np->lk);
    802025d2:	fd843783          	ld	a5,-40(s0)
    802025d6:	56878793          	addi	a5,a5,1384
    802025da:	853e                	mv	a0,a5
    802025dc:	00002097          	auipc	ra,0x2
    802025e0:	376080e7          	jalr	886(ra) # 80204952 <spinlock_acquire>
                    if (np->state == ZOMBIE) {
    802025e4:	fd843783          	ld	a5,-40(s0)
    802025e8:	439c                	lw	a5,0(a5)
    802025ea:	873e                	mv	a4,a5
    802025ec:	4795                	li	a5,5
    802025ee:	04f71263          	bne	a4,a5,80202632 <wait+0x198>
                        pid_t pid = p->pid;
    802025f2:	fd043783          	ld	a5,-48(s0)
    802025f6:	47dc                	lw	a5,12(a5)
    802025f8:	fcf42623          	sw	a5,-52(s0)
                        freeproc(np);
    802025fc:	fd843503          	ld	a0,-40(s0)
    80202600:	00000097          	auipc	ra,0x0
    80202604:	8a6080e7          	jalr	-1882(ra) # 80201ea6 <freeproc>
                        spinlock_release(&np->lk);
    80202608:	fd843783          	ld	a5,-40(s0)
    8020260c:	56878793          	addi	a5,a5,1384
    80202610:	853e                	mv	a0,a5
    80202612:	00002097          	auipc	ra,0x2
    80202616:	3b6080e7          	jalr	950(ra) # 802049c8 <spinlock_release>
                        spinlock_release(&p->lk);
    8020261a:	fd043783          	ld	a5,-48(s0)
    8020261e:	56878793          	addi	a5,a5,1384
    80202622:	853e                	mv	a0,a5
    80202624:	00002097          	auipc	ra,0x2
    80202628:	3a4080e7          	jalr	932(ra) # 802049c8 <spinlock_release>
                        return pid;
    8020262c:	fcc42783          	lw	a5,-52(s0)
    80202630:	a09d                	j	80202696 <wait+0x1fc>
                    }
                    spinlock_release(&np->lk);
    80202632:	fd843783          	ld	a5,-40(s0)
    80202636:	56878793          	addi	a5,a5,1384
    8020263a:	853e                	mv	a0,a5
    8020263c:	00002097          	auipc	ra,0x2
    80202640:	38c080e7          	jalr	908(ra) # 802049c8 <spinlock_release>
                    break;
    80202644:	a839                	j	80202662 <wait+0x1c8>
            for (proc_t* np = proc; np < &proc[NPROC]; np++) {
    80202646:	fd843783          	ld	a5,-40(s0)
    8020264a:	5d878793          	addi	a5,a5,1496
    8020264e:	fcf43c23          	sd	a5,-40(s0)
    80202652:	fd843703          	ld	a4,-40(s0)
    80202656:	00025797          	auipc	a5,0x25
    8020265a:	ec278793          	addi	a5,a5,-318 # 80227518 <cpu>
    8020265e:	f4f76fe3          	bltu	a4,a5,802025bc <wait+0x122>
                }
            }
            if (!havekids) {
    80202662:	fec42783          	lw	a5,-20(s0)
    80202666:	2781                	sext.w	a5,a5
    80202668:	eb99                	bnez	a5,8020267e <wait+0x1e4>
                spinlock_release(&p->lk);
    8020266a:	fd043783          	ld	a5,-48(s0)
    8020266e:	56878793          	addi	a5,a5,1384
    80202672:	853e                	mv	a0,a5
    80202674:	00002097          	auipc	ra,0x2
    80202678:	354080e7          	jalr	852(ra) # 802049c8 <spinlock_release>
    8020267c:	bf0d                	j	802025ae <wait+0x114>
            } else {
                sleep_spin(p, &p->lk);
    8020267e:	fd043783          	ld	a5,-48(s0)
    80202682:	56878793          	addi	a5,a5,1384
    80202686:	85be                	mv	a1,a5
    80202688:	fd043503          	ld	a0,-48(s0)
    8020268c:	00000097          	auipc	ra,0x0
    80202690:	c6e080e7          	jalr	-914(ra) # 802022fa <sleep_spin>
            for (proc_t* np = proc; np < &proc[NPROC]; np++) {
    80202694:	bf29                	j	802025ae <wait+0x114>
            }
        }
    }
    return p->pid;
}
    80202696:	853e                	mv	a0,a5
    80202698:	60a6                	ld	ra,72(sp)
    8020269a:	6406                	ld	s0,64(sp)
    8020269c:	6161                	addi	sp,sp,80
    8020269e:	8082                	ret

00000000802026a0 <fork>:

int
fork(void) {
    802026a0:	1101                	addi	sp,sp,-32
    802026a2:	ec06                	sd	ra,24(sp)
    802026a4:	e822                	sd	s0,16(sp)
    802026a6:	1000                	addi	s0,sp,32
    proc_t* newp = alloc_proc();
    802026a8:	fffff097          	auipc	ra,0xfffff
    802026ac:	642080e7          	jalr	1602(ra) # 80201cea <alloc_proc>
    802026b0:	fea43423          	sd	a0,-24(s0)
    proc_t* p = getCurrentProc();
    802026b4:	fffff097          	auipc	ra,0xfffff
    802026b8:	51a080e7          	jalr	1306(ra) # 80201bce <getCurrentProc>
    802026bc:	fea43023          	sd	a0,-32(s0)
    uvmcopy(p, newp);
    802026c0:	fe843583          	ld	a1,-24(s0)
    802026c4:	fe043503          	ld	a0,-32(s0)
    802026c8:	fffff097          	auipc	ra,0xfffff
    802026cc:	d14080e7          	jalr	-748(ra) # 802013dc <uvmcopy>
    newp->parent = p;
    802026d0:	fe843783          	ld	a5,-24(s0)
    802026d4:	fe043703          	ld	a4,-32(s0)
    802026d8:	58e7b023          	sd	a4,1408(a5)
    newp->trapFrame->a0 = 0;
    802026dc:	fe843783          	ld	a5,-24(s0)
    802026e0:	779c                	ld	a5,40(a5)
    802026e2:	0607b823          	sd	zero,112(a5)
    newp->isForked = 1;
    802026e6:	fe843783          	ld	a5,-24(s0)
    802026ea:	4705                	li	a4,1
    802026ec:	58e79823          	sh	a4,1424(a5)
    newp->state = READY;
    802026f0:	fe843783          	ld	a5,-24(s0)
    802026f4:	4709                	li	a4,2
    802026f6:	c398                	sw	a4,0(a5)
    return newp->pid;
    802026f8:	fe843783          	ld	a5,-24(s0)
    802026fc:	47dc                	lw	a5,12(a5)
}
    802026fe:	853e                	mv	a0,a5
    80202700:	60e2                	ld	ra,24(sp)
    80202702:	6442                	ld	s0,16(sp)
    80202704:	6105                	addi	sp,sp,32
    80202706:	8082                	ret

0000000080202708 <reparent>:

void
reparent(proc_t* p) {
    80202708:	7179                	addi	sp,sp,-48
    8020270a:	f422                	sd	s0,40(sp)
    8020270c:	1800                	addi	s0,sp,48
    8020270e:	fca43c23          	sd	a0,-40(s0)
    proc_t* parent_p = p->parent;
    80202712:	fd843783          	ld	a5,-40(s0)
    80202716:	5807b783          	ld	a5,1408(a5)
    8020271a:	fef43423          	sd	a5,-24(s0)
    if (p->parent != NULL) {
    8020271e:	fd843783          	ld	a5,-40(s0)
    80202722:	5807b783          	ld	a5,1408(a5)
    80202726:	cb89                	beqz	a5,80202738 <reparent+0x30>
        p->parent = parent_p->parent;
    80202728:	fe843783          	ld	a5,-24(s0)
    8020272c:	5807b703          	ld	a4,1408(a5)
    80202730:	fd843783          	ld	a5,-40(s0)
    80202734:	58e7b023          	sd	a4,1408(a5)
    }
}
    80202738:	0001                	nop
    8020273a:	7422                	ld	s0,40(sp)
    8020273c:	6145                	addi	sp,sp,48
    8020273e:	8082                	ret

0000000080202740 <printinit>:
#include "lock.h"
static char* digits = "0123456789abcdef";

spinlock_t pr_lk;
void
printinit(void) {
    80202740:	1141                	addi	sp,sp,-16
    80202742:	e406                	sd	ra,8(sp)
    80202744:	e022                	sd	s0,0(sp)
    80202746:	0800                	addi	s0,sp,16
    spinlock_init(&pr_lk, "print");
    80202748:	00009597          	auipc	a1,0x9
    8020274c:	b9858593          	addi	a1,a1,-1128 # 8020b2e0 <etext+0x2e0>
    80202750:	00025517          	auipc	a0,0x25
    80202754:	e6850513          	addi	a0,a0,-408 # 802275b8 <pr_lk>
    80202758:	00002097          	auipc	ra,0x2
    8020275c:	1ca080e7          	jalr	458(ra) # 80204922 <spinlock_init>
}
    80202760:	0001                	nop
    80202762:	60a2                	ld	ra,8(sp)
    80202764:	6402                	ld	s0,0(sp)
    80202766:	0141                	addi	sp,sp,16
    80202768:	8082                	ret

000000008020276a <printint>:
static void
printint(int data, int base) {
    8020276a:	7139                	addi	sp,sp,-64
    8020276c:	fc06                	sd	ra,56(sp)
    8020276e:	f822                	sd	s0,48(sp)
    80202770:	0080                	addi	s0,sp,64
    80202772:	87aa                	mv	a5,a0
    80202774:	872e                	mv	a4,a1
    80202776:	fcf42623          	sw	a5,-52(s0)
    8020277a:	87ba                	mv	a5,a4
    8020277c:	fcf42423          	sw	a5,-56(s0)
    char result[16];
    uint32_t num;
    if ((data < 0) && (base == 10)) {
    80202780:	fcc42783          	lw	a5,-52(s0)
    80202784:	2781                	sext.w	a5,a5
    80202786:	0207d763          	bgez	a5,802027b4 <printint+0x4a>
    8020278a:	fc842783          	lw	a5,-56(s0)
    8020278e:	0007871b          	sext.w	a4,a5
    80202792:	47a9                	li	a5,10
    80202794:	02f71063          	bne	a4,a5,802027b4 <printint+0x4a>
        console_putc('-');
    80202798:	02d00513          	li	a0,45
    8020279c:	ffffe097          	auipc	ra,0xffffe
    802027a0:	abe080e7          	jalr	-1346(ra) # 8020025a <console_putc>
        num = -data;
    802027a4:	fcc42783          	lw	a5,-52(s0)
    802027a8:	40f007bb          	negw	a5,a5
    802027ac:	2781                	sext.w	a5,a5
    802027ae:	fef42623          	sw	a5,-20(s0)
    802027b2:	a029                	j	802027bc <printint+0x52>
    } else
        num = data;
    802027b4:	fcc42783          	lw	a5,-52(s0)
    802027b8:	fef42623          	sw	a5,-20(s0)
    int count = -1;
    802027bc:	57fd                	li	a5,-1
    802027be:	fef42423          	sw	a5,-24(s0)
    do {
        count++;
    802027c2:	fe842783          	lw	a5,-24(s0)
    802027c6:	2785                	addiw	a5,a5,1
    802027c8:	fef42423          	sw	a5,-24(s0)
        result[count] = digits[num % base];
    802027cc:	0000a797          	auipc	a5,0xa
    802027d0:	1f478793          	addi	a5,a5,500 # 8020c9c0 <digits>
    802027d4:	6398                	ld	a4,0(a5)
    802027d6:	fc842783          	lw	a5,-56(s0)
    802027da:	fec42683          	lw	a3,-20(s0)
    802027de:	02f6f7bb          	remuw	a5,a3,a5
    802027e2:	2781                	sext.w	a5,a5
    802027e4:	1782                	slli	a5,a5,0x20
    802027e6:	9381                	srli	a5,a5,0x20
    802027e8:	97ba                	add	a5,a5,a4
    802027ea:	0007c703          	lbu	a4,0(a5)
    802027ee:	fe842783          	lw	a5,-24(s0)
    802027f2:	ff040693          	addi	a3,s0,-16
    802027f6:	97b6                	add	a5,a5,a3
    802027f8:	fee78423          	sb	a4,-24(a5)
    } while ((num /= base) != 0);
    802027fc:	fc842783          	lw	a5,-56(s0)
    80202800:	fec42703          	lw	a4,-20(s0)
    80202804:	02f757bb          	divuw	a5,a4,a5
    80202808:	fef42623          	sw	a5,-20(s0)
    8020280c:	fec42783          	lw	a5,-20(s0)
    80202810:	2781                	sext.w	a5,a5
    80202812:	fbc5                	bnez	a5,802027c2 <printint+0x58>

    for (; count >= 0; count--)
    80202814:	a01d                	j	8020283a <printint+0xd0>
        console_putc(result[count]);
    80202816:	fe842783          	lw	a5,-24(s0)
    8020281a:	ff040713          	addi	a4,s0,-16
    8020281e:	97ba                	add	a5,a5,a4
    80202820:	fe87c783          	lbu	a5,-24(a5)
    80202824:	2781                	sext.w	a5,a5
    80202826:	853e                	mv	a0,a5
    80202828:	ffffe097          	auipc	ra,0xffffe
    8020282c:	a32080e7          	jalr	-1486(ra) # 8020025a <console_putc>
    for (; count >= 0; count--)
    80202830:	fe842783          	lw	a5,-24(s0)
    80202834:	37fd                	addiw	a5,a5,-1
    80202836:	fef42423          	sw	a5,-24(s0)
    8020283a:	fe842783          	lw	a5,-24(s0)
    8020283e:	2781                	sext.w	a5,a5
    80202840:	fc07dbe3          	bgez	a5,80202816 <printint+0xac>
    return;
    80202844:	0001                	nop
}
    80202846:	70e2                	ld	ra,56(sp)
    80202848:	7442                	ld	s0,48(sp)
    8020284a:	6121                	addi	sp,sp,64
    8020284c:	8082                	ret

000000008020284e <printptr>:

static void
printptr(address_t ptr) {
    8020284e:	7179                	addi	sp,sp,-48
    80202850:	f406                	sd	ra,40(sp)
    80202852:	f022                	sd	s0,32(sp)
    80202854:	1800                	addi	s0,sp,48
    80202856:	fca43c23          	sd	a0,-40(s0)
    console_putc('0');
    8020285a:	03000513          	li	a0,48
    8020285e:	ffffe097          	auipc	ra,0xffffe
    80202862:	9fc080e7          	jalr	-1540(ra) # 8020025a <console_putc>
    console_putc('x');
    80202866:	07800513          	li	a0,120
    8020286a:	ffffe097          	auipc	ra,0xffffe
    8020286e:	9f0080e7          	jalr	-1552(ra) # 8020025a <console_putc>
    for (int i = 0; i < UINT64_LEN; i++) {
    80202872:	fe042623          	sw	zero,-20(s0)
    80202876:	a825                	j	802028ae <printptr+0x60>
        console_putc(digits[ptr >> (UINT64_LEN * 4 - 4)]);
    80202878:	0000a797          	auipc	a5,0xa
    8020287c:	14878793          	addi	a5,a5,328 # 8020c9c0 <digits>
    80202880:	6398                	ld	a4,0(a5)
    80202882:	fd843783          	ld	a5,-40(s0)
    80202886:	93f1                	srli	a5,a5,0x3c
    80202888:	97ba                	add	a5,a5,a4
    8020288a:	0007c783          	lbu	a5,0(a5)
    8020288e:	2781                	sext.w	a5,a5
    80202890:	853e                	mv	a0,a5
    80202892:	ffffe097          	auipc	ra,0xffffe
    80202896:	9c8080e7          	jalr	-1592(ra) # 8020025a <console_putc>
        ptr <<= 4;
    8020289a:	fd843783          	ld	a5,-40(s0)
    8020289e:	0792                	slli	a5,a5,0x4
    802028a0:	fcf43c23          	sd	a5,-40(s0)
    for (int i = 0; i < UINT64_LEN; i++) {
    802028a4:	fec42783          	lw	a5,-20(s0)
    802028a8:	2785                	addiw	a5,a5,1
    802028aa:	fef42623          	sw	a5,-20(s0)
    802028ae:	fec42783          	lw	a5,-20(s0)
    802028b2:	0007871b          	sext.w	a4,a5
    802028b6:	47bd                	li	a5,15
    802028b8:	fce7d0e3          	bge	a5,a4,80202878 <printptr+0x2a>
    }
}
    802028bc:	0001                	nop
    802028be:	0001                	nop
    802028c0:	70a2                	ld	ra,40(sp)
    802028c2:	7402                	ld	s0,32(sp)
    802028c4:	6145                	addi	sp,sp,48
    802028c6:	8082                	ret

00000000802028c8 <putchar>:

int
putchar(int c) {
    802028c8:	1101                	addi	sp,sp,-32
    802028ca:	ec06                	sd	ra,24(sp)
    802028cc:	e822                	sd	s0,16(sp)
    802028ce:	1000                	addi	s0,sp,32
    802028d0:	87aa                	mv	a5,a0
    802028d2:	fef42623          	sw	a5,-20(s0)
    console_putc(c);
    802028d6:	fec42783          	lw	a5,-20(s0)
    802028da:	853e                	mv	a0,a5
    802028dc:	ffffe097          	auipc	ra,0xffffe
    802028e0:	97e080e7          	jalr	-1666(ra) # 8020025a <console_putc>
    return c;
    802028e4:	fec42783          	lw	a5,-20(s0)
}
    802028e8:	853e                	mv	a0,a5
    802028ea:	60e2                	ld	ra,24(sp)
    802028ec:	6442                	ld	s0,16(sp)
    802028ee:	6105                	addi	sp,sp,32
    802028f0:	8082                	ret

00000000802028f2 <printf>:

int
printf(char* fmt, ...) {
    802028f2:	7119                	addi	sp,sp,-128
    802028f4:	fc06                	sd	ra,56(sp)
    802028f6:	f822                	sd	s0,48(sp)
    802028f8:	0080                	addi	s0,sp,64
    802028fa:	fca43423          	sd	a0,-56(s0)
    802028fe:	e40c                	sd	a1,8(s0)
    80202900:	e810                	sd	a2,16(s0)
    80202902:	ec14                	sd	a3,24(s0)
    80202904:	f018                	sd	a4,32(s0)
    80202906:	f41c                	sd	a5,40(s0)
    80202908:	03043823          	sd	a6,48(s0)
    8020290c:	03143c23          	sd	a7,56(s0)
    va_list ap;
    va_start(ap, fmt);
    80202910:	04040793          	addi	a5,s0,64
    80202914:	fcf43023          	sd	a5,-64(s0)
    80202918:	fc043783          	ld	a5,-64(s0)
    8020291c:	fc878793          	addi	a5,a5,-56
    80202920:	fcf43823          	sd	a5,-48(s0)
    int ch;
    char* str;
    int count = 0;
    80202924:	fe042623          	sw	zero,-20(s0)
    //    const char percentage = '%';
    spinlock_acquire(&pr_lk);
    80202928:	00025517          	auipc	a0,0x25
    8020292c:	c9050513          	addi	a0,a0,-880 # 802275b8 <pr_lk>
    80202930:	00002097          	auipc	ra,0x2
    80202934:	022080e7          	jalr	34(ra) # 80204952 <spinlock_acquire>
    for (int i = 0; (ch = fmt[i] & 0xff) != 0; i++) {
    80202938:	fe042423          	sw	zero,-24(s0)
    8020293c:	a279                	j	80202aca <printf+0x1d8>
        if (ch != '%') {
    8020293e:	fe042783          	lw	a5,-32(s0)
    80202942:	0007871b          	sext.w	a4,a5
    80202946:	02500793          	li	a5,37
    8020294a:	00f70a63          	beq	a4,a5,8020295e <printf+0x6c>
            console_putc(ch);
    8020294e:	fe042783          	lw	a5,-32(s0)
    80202952:	853e                	mv	a0,a5
    80202954:	ffffe097          	auipc	ra,0xffffe
    80202958:	906080e7          	jalr	-1786(ra) # 8020025a <console_putc>

            continue;
    8020295c:	a295                	j	80202ac0 <printf+0x1ce>
        }
        i++;
    8020295e:	fe842783          	lw	a5,-24(s0)
    80202962:	2785                	addiw	a5,a5,1
    80202964:	fef42423          	sw	a5,-24(s0)
        ch = fmt[i] & 0xff;
    80202968:	fe842783          	lw	a5,-24(s0)
    8020296c:	fc843703          	ld	a4,-56(s0)
    80202970:	97ba                	add	a5,a5,a4
    80202972:	0007c783          	lbu	a5,0(a5)
    80202976:	fef42023          	sw	a5,-32(s0)
        switch (ch) {
    8020297a:	fe042783          	lw	a5,-32(s0)
    8020297e:	0007871b          	sext.w	a4,a5
    80202982:	07800793          	li	a5,120
    80202986:	06f70e63          	beq	a4,a5,80202a02 <printf+0x110>
    8020298a:	fe042783          	lw	a5,-32(s0)
    8020298e:	0007871b          	sext.w	a4,a5
    80202992:	07800793          	li	a5,120
    80202996:	10e7c763          	blt	a5,a4,80202aa4 <printf+0x1b2>
    8020299a:	fe042783          	lw	a5,-32(s0)
    8020299e:	0007871b          	sext.w	a4,a5
    802029a2:	07300793          	li	a5,115
    802029a6:	08f70163          	beq	a4,a5,80202a28 <printf+0x136>
    802029aa:	fe042783          	lw	a5,-32(s0)
    802029ae:	0007871b          	sext.w	a4,a5
    802029b2:	07300793          	li	a5,115
    802029b6:	0ee7c763          	blt	a5,a4,80202aa4 <printf+0x1b2>
    802029ba:	fe042783          	lw	a5,-32(s0)
    802029be:	0007871b          	sext.w	a4,a5
    802029c2:	06400793          	li	a5,100
    802029c6:	00f70b63          	beq	a4,a5,802029dc <printf+0xea>
    802029ca:	fe042783          	lw	a5,-32(s0)
    802029ce:	0007871b          	sext.w	a4,a5
    802029d2:	07000793          	li	a5,112
    802029d6:	0af70563          	beq	a4,a5,80202a80 <printf+0x18e>
    802029da:	a0e9                	j	80202aa4 <printf+0x1b2>
            case 'd': {
                printint(va_arg(ap, int), 10);
    802029dc:	fd043783          	ld	a5,-48(s0)
    802029e0:	00878713          	addi	a4,a5,8
    802029e4:	fce43823          	sd	a4,-48(s0)
    802029e8:	439c                	lw	a5,0(a5)
    802029ea:	45a9                	li	a1,10
    802029ec:	853e                	mv	a0,a5
    802029ee:	00000097          	auipc	ra,0x0
    802029f2:	d7c080e7          	jalr	-644(ra) # 8020276a <printint>
                count++;
    802029f6:	fec42783          	lw	a5,-20(s0)
    802029fa:	2785                	addiw	a5,a5,1
    802029fc:	fef42623          	sw	a5,-20(s0)
                break;
    80202a00:	a0c1                	j	80202ac0 <printf+0x1ce>
            }
            case 'x': {
                printint(va_arg(ap, int), 16);
    80202a02:	fd043783          	ld	a5,-48(s0)
    80202a06:	00878713          	addi	a4,a5,8
    80202a0a:	fce43823          	sd	a4,-48(s0)
    80202a0e:	439c                	lw	a5,0(a5)
    80202a10:	45c1                	li	a1,16
    80202a12:	853e                	mv	a0,a5
    80202a14:	00000097          	auipc	ra,0x0
    80202a18:	d56080e7          	jalr	-682(ra) # 8020276a <printint>
                count++;
    80202a1c:	fec42783          	lw	a5,-20(s0)
    80202a20:	2785                	addiw	a5,a5,1
    80202a22:	fef42623          	sw	a5,-20(s0)
                break;
    80202a26:	a869                	j	80202ac0 <printf+0x1ce>
            }
            case 's': {
                str = va_arg(ap, char*);
    80202a28:	fd043783          	ld	a5,-48(s0)
    80202a2c:	00878713          	addi	a4,a5,8
    80202a30:	fce43823          	sd	a4,-48(s0)
    80202a34:	639c                	ld	a5,0(a5)
    80202a36:	fcf43c23          	sd	a5,-40(s0)
                for (int i = 0; str[i] != '\0'; i++) {
    80202a3a:	fe042223          	sw	zero,-28(s0)
    80202a3e:	a01d                	j	80202a64 <printf+0x172>
                    console_putc(str[i]);
    80202a40:	fe442783          	lw	a5,-28(s0)
    80202a44:	fd843703          	ld	a4,-40(s0)
    80202a48:	97ba                	add	a5,a5,a4
    80202a4a:	0007c783          	lbu	a5,0(a5)
    80202a4e:	2781                	sext.w	a5,a5
    80202a50:	853e                	mv	a0,a5
    80202a52:	ffffe097          	auipc	ra,0xffffe
    80202a56:	808080e7          	jalr	-2040(ra) # 8020025a <console_putc>
                for (int i = 0; str[i] != '\0'; i++) {
    80202a5a:	fe442783          	lw	a5,-28(s0)
    80202a5e:	2785                	addiw	a5,a5,1
    80202a60:	fef42223          	sw	a5,-28(s0)
    80202a64:	fe442783          	lw	a5,-28(s0)
    80202a68:	fd843703          	ld	a4,-40(s0)
    80202a6c:	97ba                	add	a5,a5,a4
    80202a6e:	0007c783          	lbu	a5,0(a5)
    80202a72:	f7f9                	bnez	a5,80202a40 <printf+0x14e>
                }
                count++;
    80202a74:	fec42783          	lw	a5,-20(s0)
    80202a78:	2785                	addiw	a5,a5,1
    80202a7a:	fef42623          	sw	a5,-20(s0)
                break;
    80202a7e:	a089                	j	80202ac0 <printf+0x1ce>
            }
            case 'p': {
                printptr(va_arg(ap, address_t));
    80202a80:	fd043783          	ld	a5,-48(s0)
    80202a84:	00878713          	addi	a4,a5,8
    80202a88:	fce43823          	sd	a4,-48(s0)
    80202a8c:	639c                	ld	a5,0(a5)
    80202a8e:	853e                	mv	a0,a5
    80202a90:	00000097          	auipc	ra,0x0
    80202a94:	dbe080e7          	jalr	-578(ra) # 8020284e <printptr>
                count++;
    80202a98:	fec42783          	lw	a5,-20(s0)
    80202a9c:	2785                	addiw	a5,a5,1
    80202a9e:	fef42623          	sw	a5,-20(s0)
                break;
    80202aa2:	a839                	j	80202ac0 <printf+0x1ce>
            }
            default:
                // Print unknown % sequence to draw attention
                console_putc('%');
    80202aa4:	02500513          	li	a0,37
    80202aa8:	ffffd097          	auipc	ra,0xffffd
    80202aac:	7b2080e7          	jalr	1970(ra) # 8020025a <console_putc>
                console_putc(ch);
    80202ab0:	fe042783          	lw	a5,-32(s0)
    80202ab4:	853e                	mv	a0,a5
    80202ab6:	ffffd097          	auipc	ra,0xffffd
    80202aba:	7a4080e7          	jalr	1956(ra) # 8020025a <console_putc>
                break;
    80202abe:	0001                	nop
    for (int i = 0; (ch = fmt[i] & 0xff) != 0; i++) {
    80202ac0:	fe842783          	lw	a5,-24(s0)
    80202ac4:	2785                	addiw	a5,a5,1
    80202ac6:	fef42423          	sw	a5,-24(s0)
    80202aca:	fe842783          	lw	a5,-24(s0)
    80202ace:	fc843703          	ld	a4,-56(s0)
    80202ad2:	97ba                	add	a5,a5,a4
    80202ad4:	0007c783          	lbu	a5,0(a5)
    80202ad8:	fef42023          	sw	a5,-32(s0)
    80202adc:	fe042783          	lw	a5,-32(s0)
    80202ae0:	2781                	sext.w	a5,a5
    80202ae2:	e4079ee3          	bnez	a5,8020293e <printf+0x4c>
        }
    }
    spinlock_release(&pr_lk);
    80202ae6:	00025517          	auipc	a0,0x25
    80202aea:	ad250513          	addi	a0,a0,-1326 # 802275b8 <pr_lk>
    80202aee:	00002097          	auipc	ra,0x2
    80202af2:	eda080e7          	jalr	-294(ra) # 802049c8 <spinlock_release>
    return count;
    80202af6:	fec42783          	lw	a5,-20(s0)
}
    80202afa:	853e                	mv	a0,a5
    80202afc:	70e2                	ld	ra,56(sp)
    80202afe:	7442                	ld	s0,48(sp)
    80202b00:	6109                	addi	sp,sp,128
    80202b02:	8082                	ret

0000000080202b04 <panic>:

void
panic(char* s) {
    80202b04:	1101                	addi	sp,sp,-32
    80202b06:	ec06                	sd	ra,24(sp)
    80202b08:	e822                	sd	s0,16(sp)
    80202b0a:	1000                	addi	s0,sp,32
    80202b0c:	fea43423          	sd	a0,-24(s0)
    printf("panic: %s\n", s);
    80202b10:	fe843583          	ld	a1,-24(s0)
    80202b14:	00008517          	auipc	a0,0x8
    80202b18:	7d450513          	addi	a0,a0,2004 # 8020b2e8 <etext+0x2e8>
    80202b1c:	00000097          	auipc	ra,0x0
    80202b20:	dd6080e7          	jalr	-554(ra) # 802028f2 <printf>
    // printf(s);
    // printf("\n");
    while (1)
    80202b24:	a001                	j	80202b24 <panic+0x20>

0000000080202b26 <memset>:
#include "mmu.h"

#include "string.h"

void*
memset(void* dst, byte_t c, size_t size) {
    80202b26:	7139                	addi	sp,sp,-64
    80202b28:	fc22                	sd	s0,56(sp)
    80202b2a:	0080                	addi	s0,sp,64
    80202b2c:	fca43c23          	sd	a0,-40(s0)
    80202b30:	87ae                	mv	a5,a1
    80202b32:	fcc43423          	sd	a2,-56(s0)
    80202b36:	fcf40ba3          	sb	a5,-41(s0)
    byte_t* temp = (byte_t*)dst;
    80202b3a:	fd843783          	ld	a5,-40(s0)
    80202b3e:	fef43023          	sd	a5,-32(s0)
    for (int i = 0; i < size; i++)
    80202b42:	fe042623          	sw	zero,-20(s0)
    80202b46:	a839                	j	80202b64 <memset+0x3e>
        temp[i] = c;
    80202b48:	fec42783          	lw	a5,-20(s0)
    80202b4c:	fe043703          	ld	a4,-32(s0)
    80202b50:	97ba                	add	a5,a5,a4
    80202b52:	fd744703          	lbu	a4,-41(s0)
    80202b56:	00e78023          	sb	a4,0(a5)
    for (int i = 0; i < size; i++)
    80202b5a:	fec42783          	lw	a5,-20(s0)
    80202b5e:	2785                	addiw	a5,a5,1
    80202b60:	fef42623          	sw	a5,-20(s0)
    80202b64:	fec42783          	lw	a5,-20(s0)
    80202b68:	fc843703          	ld	a4,-56(s0)
    80202b6c:	fce7eee3          	bltu	a5,a4,80202b48 <memset+0x22>

    return dst;
    80202b70:	fd843783          	ld	a5,-40(s0)
}
    80202b74:	853e                	mv	a0,a5
    80202b76:	7462                	ld	s0,56(sp)
    80202b78:	6121                	addi	sp,sp,64
    80202b7a:	8082                	ret

0000000080202b7c <memmove>:

void*
memmove(void* dst, void* src, size_t size) {
    80202b7c:	7139                	addi	sp,sp,-64
    80202b7e:	fc22                	sd	s0,56(sp)
    80202b80:	0080                	addi	s0,sp,64
    80202b82:	fca43c23          	sd	a0,-40(s0)
    80202b86:	fcb43823          	sd	a1,-48(s0)
    80202b8a:	fcc43423          	sd	a2,-56(s0)
    byte_t* d = dst;
    80202b8e:	fd843783          	ld	a5,-40(s0)
    80202b92:	fef43423          	sd	a5,-24(s0)
    byte_t* s = src;
    80202b96:	fd043783          	ld	a5,-48(s0)
    80202b9a:	fef43023          	sd	a5,-32(s0)
    while (size > 0) {
    80202b9e:	a035                	j	80202bca <memmove+0x4e>
        *d++ = *s++;
    80202ba0:	fe043703          	ld	a4,-32(s0)
    80202ba4:	00170793          	addi	a5,a4,1
    80202ba8:	fef43023          	sd	a5,-32(s0)
    80202bac:	fe843783          	ld	a5,-24(s0)
    80202bb0:	00178693          	addi	a3,a5,1
    80202bb4:	fed43423          	sd	a3,-24(s0)
    80202bb8:	00074703          	lbu	a4,0(a4)
    80202bbc:	00e78023          	sb	a4,0(a5)
        size--;
    80202bc0:	fc843783          	ld	a5,-56(s0)
    80202bc4:	17fd                	addi	a5,a5,-1
    80202bc6:	fcf43423          	sd	a5,-56(s0)
    while (size > 0) {
    80202bca:	fc843783          	ld	a5,-56(s0)
    80202bce:	fbe9                	bnez	a5,80202ba0 <memmove+0x24>
    }
    return dst;
    80202bd0:	fd843783          	ld	a5,-40(s0)
}
    80202bd4:	853e                	mv	a0,a5
    80202bd6:	7462                	ld	s0,56(sp)
    80202bd8:	6121                	addi	sp,sp,64
    80202bda:	8082                	ret

0000000080202bdc <memcpy>:

void*
memcpy(void* dst, const void* src, size_t n) {
    80202bdc:	7139                	addi	sp,sp,-64
    80202bde:	fc22                	sd	s0,56(sp)
    80202be0:	0080                	addi	s0,sp,64
    80202be2:	fca43c23          	sd	a0,-40(s0)
    80202be6:	fcb43823          	sd	a1,-48(s0)
    80202bea:	fcc43423          	sd	a2,-56(s0)
    const char* s = (char*)src;
    80202bee:	fd043783          	ld	a5,-48(s0)
    80202bf2:	fef43423          	sd	a5,-24(s0)
    char* d = (char*)dst;
    80202bf6:	fd843783          	ld	a5,-40(s0)
    80202bfa:	fef43023          	sd	a5,-32(s0)
    while (n > 0) {
    80202bfe:	a805                	j	80202c2e <memcpy+0x52>
        *d = *s;
    80202c00:	fe843783          	ld	a5,-24(s0)
    80202c04:	0007c703          	lbu	a4,0(a5)
    80202c08:	fe043783          	ld	a5,-32(s0)
    80202c0c:	00e78023          	sb	a4,0(a5)
        ++d, ++s;
    80202c10:	fe043783          	ld	a5,-32(s0)
    80202c14:	0785                	addi	a5,a5,1
    80202c16:	fef43023          	sd	a5,-32(s0)
    80202c1a:	fe843783          	ld	a5,-24(s0)
    80202c1e:	0785                	addi	a5,a5,1
    80202c20:	fef43423          	sd	a5,-24(s0)
        --n;
    80202c24:	fc843783          	ld	a5,-56(s0)
    80202c28:	17fd                	addi	a5,a5,-1
    80202c2a:	fcf43423          	sd	a5,-56(s0)
    while (n > 0) {
    80202c2e:	fc843783          	ld	a5,-56(s0)
    80202c32:	f7f9                	bnez	a5,80202c00 <memcpy+0x24>
    }
    return dst;
    80202c34:	fd843783          	ld	a5,-40(s0)
}
    80202c38:	853e                	mv	a0,a5
    80202c3a:	7462                	ld	s0,56(sp)
    80202c3c:	6121                	addi	sp,sp,64
    80202c3e:	8082                	ret

0000000080202c40 <strncmp>:

int
strncmp(const char* s1, const char* s2, uint32_t len) {
    80202c40:	7139                	addi	sp,sp,-64
    80202c42:	fc22                	sd	s0,56(sp)
    80202c44:	0080                	addi	s0,sp,64
    80202c46:	fca43c23          	sd	a0,-40(s0)
    80202c4a:	fcb43823          	sd	a1,-48(s0)
    80202c4e:	87b2                	mv	a5,a2
    80202c50:	fcf42623          	sw	a5,-52(s0)
    uint32_t i = 0;
    80202c54:	fe042623          	sw	zero,-20(s0)
    while ((s1[i] != '\0') && (i < len - 1) && (s1[i] == s2[i]))
    80202c58:	a031                	j	80202c64 <strncmp+0x24>
        ++i;
    80202c5a:	fec42783          	lw	a5,-20(s0)
    80202c5e:	2785                	addiw	a5,a5,1
    80202c60:	fef42623          	sw	a5,-20(s0)
    while ((s1[i] != '\0') && (i < len - 1) && (s1[i] == s2[i]))
    80202c64:	fec46783          	lwu	a5,-20(s0)
    80202c68:	fd843703          	ld	a4,-40(s0)
    80202c6c:	97ba                	add	a5,a5,a4
    80202c6e:	0007c783          	lbu	a5,0(a5)
    80202c72:	cf85                	beqz	a5,80202caa <strncmp+0x6a>
    80202c74:	fcc42783          	lw	a5,-52(s0)
    80202c78:	37fd                	addiw	a5,a5,-1
    80202c7a:	0007871b          	sext.w	a4,a5
    80202c7e:	fec42783          	lw	a5,-20(s0)
    80202c82:	2781                	sext.w	a5,a5
    80202c84:	02e7f363          	bgeu	a5,a4,80202caa <strncmp+0x6a>
    80202c88:	fec46783          	lwu	a5,-20(s0)
    80202c8c:	fd843703          	ld	a4,-40(s0)
    80202c90:	97ba                	add	a5,a5,a4
    80202c92:	0007c683          	lbu	a3,0(a5)
    80202c96:	fec46783          	lwu	a5,-20(s0)
    80202c9a:	fd043703          	ld	a4,-48(s0)
    80202c9e:	97ba                	add	a5,a5,a4
    80202ca0:	0007c783          	lbu	a5,0(a5)
    80202ca4:	8736                	mv	a4,a3
    80202ca6:	faf70ae3          	beq	a4,a5,80202c5a <strncmp+0x1a>
    return (int)(s1[i] - s2[i]);
    80202caa:	fec46783          	lwu	a5,-20(s0)
    80202cae:	fd843703          	ld	a4,-40(s0)
    80202cb2:	97ba                	add	a5,a5,a4
    80202cb4:	0007c783          	lbu	a5,0(a5)
    80202cb8:	0007871b          	sext.w	a4,a5
    80202cbc:	fec46783          	lwu	a5,-20(s0)
    80202cc0:	fd043683          	ld	a3,-48(s0)
    80202cc4:	97b6                	add	a5,a5,a3
    80202cc6:	0007c783          	lbu	a5,0(a5)
    80202cca:	2781                	sext.w	a5,a5
    80202ccc:	40f707bb          	subw	a5,a4,a5
    80202cd0:	2781                	sext.w	a5,a5
}
    80202cd2:	853e                	mv	a0,a5
    80202cd4:	7462                	ld	s0,56(sp)
    80202cd6:	6121                	addi	sp,sp,64
    80202cd8:	8082                	ret

0000000080202cda <strcmp>:

int
strcmp(const char* s1, const char* s2) {
    80202cda:	1101                	addi	sp,sp,-32
    80202cdc:	ec22                	sd	s0,24(sp)
    80202cde:	1000                	addi	s0,sp,32
    80202ce0:	fea43423          	sd	a0,-24(s0)
    80202ce4:	feb43023          	sd	a1,-32(s0)
    while (*s1 && *s1 == *s2)
    80202ce8:	a819                	j	80202cfe <strcmp+0x24>
        ++s1, ++s2;
    80202cea:	fe843783          	ld	a5,-24(s0)
    80202cee:	0785                	addi	a5,a5,1
    80202cf0:	fef43423          	sd	a5,-24(s0)
    80202cf4:	fe043783          	ld	a5,-32(s0)
    80202cf8:	0785                	addi	a5,a5,1
    80202cfa:	fef43023          	sd	a5,-32(s0)
    while (*s1 && *s1 == *s2)
    80202cfe:	fe843783          	ld	a5,-24(s0)
    80202d02:	0007c783          	lbu	a5,0(a5)
    80202d06:	cb99                	beqz	a5,80202d1c <strcmp+0x42>
    80202d08:	fe843783          	ld	a5,-24(s0)
    80202d0c:	0007c703          	lbu	a4,0(a5)
    80202d10:	fe043783          	ld	a5,-32(s0)
    80202d14:	0007c783          	lbu	a5,0(a5)
    80202d18:	fcf709e3          	beq	a4,a5,80202cea <strcmp+0x10>
    return (int)(*s1 - *s2);
    80202d1c:	fe843783          	ld	a5,-24(s0)
    80202d20:	0007c783          	lbu	a5,0(a5)
    80202d24:	0007871b          	sext.w	a4,a5
    80202d28:	fe043783          	ld	a5,-32(s0)
    80202d2c:	0007c783          	lbu	a5,0(a5)
    80202d30:	2781                	sext.w	a5,a5
    80202d32:	40f707bb          	subw	a5,a4,a5
    80202d36:	2781                	sext.w	a5,a5
}
    80202d38:	853e                	mv	a0,a5
    80202d3a:	6462                	ld	s0,24(sp)
    80202d3c:	6105                	addi	sp,sp,32
    80202d3e:	8082                	ret

0000000080202d40 <strcpy>:

char*
strcpy(char* dst, const char* src) {
    80202d40:	7179                	addi	sp,sp,-48
    80202d42:	f422                	sd	s0,40(sp)
    80202d44:	1800                	addi	s0,sp,48
    80202d46:	fca43c23          	sd	a0,-40(s0)
    80202d4a:	fcb43823          	sd	a1,-48(s0)
    char* p = dst;
    80202d4e:	fd843783          	ld	a5,-40(s0)
    80202d52:	fef43423          	sd	a5,-24(s0)
    while (*src != '\0') {
    80202d56:	a01d                	j	80202d7c <strcpy+0x3c>
        *p = *src;
    80202d58:	fd043783          	ld	a5,-48(s0)
    80202d5c:	0007c703          	lbu	a4,0(a5)
    80202d60:	fe843783          	ld	a5,-24(s0)
    80202d64:	00e78023          	sb	a4,0(a5)
        ++p;
    80202d68:	fe843783          	ld	a5,-24(s0)
    80202d6c:	0785                	addi	a5,a5,1
    80202d6e:	fef43423          	sd	a5,-24(s0)
        ++src;
    80202d72:	fd043783          	ld	a5,-48(s0)
    80202d76:	0785                	addi	a5,a5,1
    80202d78:	fcf43823          	sd	a5,-48(s0)
    while (*src != '\0') {
    80202d7c:	fd043783          	ld	a5,-48(s0)
    80202d80:	0007c783          	lbu	a5,0(a5)
    80202d84:	fbf1                	bnez	a5,80202d58 <strcpy+0x18>
    }
    *p = '\0';
    80202d86:	fe843783          	ld	a5,-24(s0)
    80202d8a:	00078023          	sb	zero,0(a5)
    return dst;
    80202d8e:	fd843783          	ld	a5,-40(s0)
}
    80202d92:	853e                	mv	a0,a5
    80202d94:	7422                	ld	s0,40(sp)
    80202d96:	6145                	addi	sp,sp,48
    80202d98:	8082                	ret

0000000080202d9a <strncpy>:

char*
strncpy(char* dst, const char* src, uint32_t len) {
    80202d9a:	7179                	addi	sp,sp,-48
    80202d9c:	f422                	sd	s0,40(sp)
    80202d9e:	1800                	addi	s0,sp,48
    80202da0:	fea43423          	sd	a0,-24(s0)
    80202da4:	feb43023          	sd	a1,-32(s0)
    80202da8:	87b2                	mv	a5,a2
    80202daa:	fcf42e23          	sw	a5,-36(s0)
    while (len > 0 && *src) {
    80202dae:	a805                	j	80202dde <strncpy+0x44>
        *dst = *src;
    80202db0:	fe043783          	ld	a5,-32(s0)
    80202db4:	0007c703          	lbu	a4,0(a5)
    80202db8:	fe843783          	ld	a5,-24(s0)
    80202dbc:	00e78023          	sb	a4,0(a5)
        ++src;
    80202dc0:	fe043783          	ld	a5,-32(s0)
    80202dc4:	0785                	addi	a5,a5,1
    80202dc6:	fef43023          	sd	a5,-32(s0)
        ++dst;
    80202dca:	fe843783          	ld	a5,-24(s0)
    80202dce:	0785                	addi	a5,a5,1
    80202dd0:	fef43423          	sd	a5,-24(s0)
        --len;
    80202dd4:	fdc42783          	lw	a5,-36(s0)
    80202dd8:	37fd                	addiw	a5,a5,-1
    80202dda:	fcf42e23          	sw	a5,-36(s0)
    while (len > 0 && *src) {
    80202dde:	fdc42783          	lw	a5,-36(s0)
    80202de2:	2781                	sext.w	a5,a5
    80202de4:	c78d                	beqz	a5,80202e0e <strncpy+0x74>
    80202de6:	fe043783          	ld	a5,-32(s0)
    80202dea:	0007c783          	lbu	a5,0(a5)
    80202dee:	f3e9                	bnez	a5,80202db0 <strncpy+0x16>
    }
    while (len > 0) {
    80202df0:	a839                	j	80202e0e <strncpy+0x74>
        *dst = '\0';
    80202df2:	fe843783          	ld	a5,-24(s0)
    80202df6:	00078023          	sb	zero,0(a5)
        ++dst;
    80202dfa:	fe843783          	ld	a5,-24(s0)
    80202dfe:	0785                	addi	a5,a5,1
    80202e00:	fef43423          	sd	a5,-24(s0)
        --len;
    80202e04:	fdc42783          	lw	a5,-36(s0)
    80202e08:	37fd                	addiw	a5,a5,-1
    80202e0a:	fcf42e23          	sw	a5,-36(s0)
    while (len > 0) {
    80202e0e:	fdc42783          	lw	a5,-36(s0)
    80202e12:	2781                	sext.w	a5,a5
    80202e14:	fff9                	bnez	a5,80202df2 <strncpy+0x58>
    }
    return dst;
    80202e16:	fe843783          	ld	a5,-24(s0)
}
    80202e1a:	853e                	mv	a0,a5
    80202e1c:	7422                	ld	s0,40(sp)
    80202e1e:	6145                	addi	sp,sp,48
    80202e20:	8082                	ret

0000000080202e22 <strchr>:

char*
strchr(const char* s, char c) {
    80202e22:	1101                	addi	sp,sp,-32
    80202e24:	ec22                	sd	s0,24(sp)
    80202e26:	1000                	addi	s0,sp,32
    80202e28:	fea43423          	sd	a0,-24(s0)
    80202e2c:	87ae                	mv	a5,a1
    80202e2e:	fef403a3          	sb	a5,-25(s0)
    for (; *s; ++s)
    80202e32:	a01d                	j	80202e58 <strchr+0x36>
        if (*s == c)
    80202e34:	fe843783          	ld	a5,-24(s0)
    80202e38:	0007c703          	lbu	a4,0(a5)
    80202e3c:	fe744783          	lbu	a5,-25(s0)
    80202e40:	0ff7f793          	zext.b	a5,a5
    80202e44:	00e79563          	bne	a5,a4,80202e4e <strchr+0x2c>
            return (char*)s;
    80202e48:	fe843783          	ld	a5,-24(s0)
    80202e4c:	a821                	j	80202e64 <strchr+0x42>
    for (; *s; ++s)
    80202e4e:	fe843783          	ld	a5,-24(s0)
    80202e52:	0785                	addi	a5,a5,1
    80202e54:	fef43423          	sd	a5,-24(s0)
    80202e58:	fe843783          	ld	a5,-24(s0)
    80202e5c:	0007c783          	lbu	a5,0(a5)
    80202e60:	fbf1                	bnez	a5,80202e34 <strchr+0x12>
    return NULL;
    80202e62:	4781                	li	a5,0
}
    80202e64:	853e                	mv	a0,a5
    80202e66:	6462                	ld	s0,24(sp)
    80202e68:	6105                	addi	sp,sp,32
    80202e6a:	8082                	ret

0000000080202e6c <strlen>:

size_t
strlen(const char* s) {
    80202e6c:	7179                	addi	sp,sp,-48
    80202e6e:	f422                	sd	s0,40(sp)
    80202e70:	1800                	addi	s0,sp,48
    80202e72:	fca43c23          	sd	a0,-40(s0)
    size_t cnt = 0;
    80202e76:	fe043423          	sd	zero,-24(s0)
    while (*s)
    80202e7a:	a819                	j	80202e90 <strlen+0x24>
        ++cnt, ++s;
    80202e7c:	fe843783          	ld	a5,-24(s0)
    80202e80:	0785                	addi	a5,a5,1
    80202e82:	fef43423          	sd	a5,-24(s0)
    80202e86:	fd843783          	ld	a5,-40(s0)
    80202e8a:	0785                	addi	a5,a5,1
    80202e8c:	fcf43c23          	sd	a5,-40(s0)
    while (*s)
    80202e90:	fd843783          	ld	a5,-40(s0)
    80202e94:	0007c783          	lbu	a5,0(a5)
    80202e98:	f3f5                	bnez	a5,80202e7c <strlen+0x10>
    return cnt;
    80202e9a:	fe843783          	ld	a5,-24(s0)
}
    80202e9e:	853e                	mv	a0,a5
    80202ea0:	7422                	ld	s0,40(sp)
    80202ea2:	6145                	addi	sp,sp,48
    80202ea4:	8082                	ret

0000000080202ea6 <strdup>:

char*
strdup(const char* src) {
    80202ea6:	7179                	addi	sp,sp,-48
    80202ea8:	f406                	sd	ra,40(sp)
    80202eaa:	f022                	sd	s0,32(sp)
    80202eac:	1800                	addi	s0,sp,48
    80202eae:	fca43c23          	sd	a0,-40(s0)
    size_t len = strlen(src);
    80202eb2:	fd843503          	ld	a0,-40(s0)
    80202eb6:	00000097          	auipc	ra,0x0
    80202eba:	fb6080e7          	jalr	-74(ra) # 80202e6c <strlen>
    80202ebe:	fea43423          	sd	a0,-24(s0)
    char* dst = kmalloc(len + 1);
    80202ec2:	fe843783          	ld	a5,-24(s0)
    80202ec6:	0785                	addi	a5,a5,1
    80202ec8:	853e                	mv	a0,a5
    80202eca:	ffffe097          	auipc	ra,0xffffe
    80202ece:	d96080e7          	jalr	-618(ra) # 80200c60 <kmalloc>
    80202ed2:	fea43023          	sd	a0,-32(s0)
    if (dst) {
    80202ed6:	fe043783          	ld	a5,-32(s0)
    80202eda:	c395                	beqz	a5,80202efe <strdup+0x58>
        memcpy(dst, src, len);
    80202edc:	fe843603          	ld	a2,-24(s0)
    80202ee0:	fd843583          	ld	a1,-40(s0)
    80202ee4:	fe043503          	ld	a0,-32(s0)
    80202ee8:	00000097          	auipc	ra,0x0
    80202eec:	cf4080e7          	jalr	-780(ra) # 80202bdc <memcpy>
        dst[len] = '\0';
    80202ef0:	fe043703          	ld	a4,-32(s0)
    80202ef4:	fe843783          	ld	a5,-24(s0)
    80202ef8:	97ba                	add	a5,a5,a4
    80202efa:	00078023          	sb	zero,0(a5)
    }
    return dst;
    80202efe:	fe043783          	ld	a5,-32(s0)
    80202f02:	853e                	mv	a0,a5
    80202f04:	70a2                	ld	ra,40(sp)
    80202f06:	7402                	ld	s0,32(sp)
    80202f08:	6145                	addi	sp,sp,48
    80202f0a:	8082                	ret

0000000080202f0c <r_time>:
{
    80202f0c:	1101                	addi	sp,sp,-32
    80202f0e:	ec22                	sd	s0,24(sp)
    80202f10:	1000                	addi	s0,sp,32
    asm volatile("rdtime %0"
    80202f12:	c01027f3          	rdtime	a5
    80202f16:	fef43423          	sd	a5,-24(s0)
    return x;
    80202f1a:	fe843783          	ld	a5,-24(s0)
}
    80202f1e:	853e                	mv	a0,a5
    80202f20:	6462                	ld	s0,24(sp)
    80202f22:	6105                	addi	sp,sp,32
    80202f24:	8082                	ret

0000000080202f26 <getParameter>:
} utsname_t;

utsname_t utsname = {"di", "san", "1.0", "1.0", "riscv64", "102"};

register_t
getParameter(int n) {
    80202f26:	7179                	addi	sp,sp,-48
    80202f28:	f406                	sd	ra,40(sp)
    80202f2a:	f022                	sd	s0,32(sp)
    80202f2c:	1800                	addi	s0,sp,48
    80202f2e:	87aa                	mv	a5,a0
    80202f30:	fcf42e23          	sw	a5,-36(s0)
    proc_t* p = getCurrentProc();
    80202f34:	fffff097          	auipc	ra,0xfffff
    80202f38:	c9a080e7          	jalr	-870(ra) # 80201bce <getCurrentProc>
    80202f3c:	fea43423          	sd	a0,-24(s0)
    80202f40:	fdc42783          	lw	a5,-36(s0)
    80202f44:	0007871b          	sext.w	a4,a5
    80202f48:	4795                	li	a5,5
    80202f4a:	06e7e263          	bltu	a5,a4,80202fae <getParameter+0x88>
    80202f4e:	fdc46783          	lwu	a5,-36(s0)
    80202f52:	00279713          	slli	a4,a5,0x2
    80202f56:	00008797          	auipc	a5,0x8
    80202f5a:	3b278793          	addi	a5,a5,946 # 8020b308 <etext+0x308>
    80202f5e:	97ba                	add	a5,a5,a4
    80202f60:	439c                	lw	a5,0(a5)
    80202f62:	0007871b          	sext.w	a4,a5
    80202f66:	00008797          	auipc	a5,0x8
    80202f6a:	3a278793          	addi	a5,a5,930 # 8020b308 <etext+0x308>
    80202f6e:	97ba                	add	a5,a5,a4
    80202f70:	8782                	jr	a5
    switch (n) {
        case 0:
            return p->trapFrame->a0;
    80202f72:	fe843783          	ld	a5,-24(s0)
    80202f76:	779c                	ld	a5,40(a5)
    80202f78:	7bbc                	ld	a5,112(a5)
    80202f7a:	a099                	j	80202fc0 <getParameter+0x9a>
        case 1:
            return p->trapFrame->a1;
    80202f7c:	fe843783          	ld	a5,-24(s0)
    80202f80:	779c                	ld	a5,40(a5)
    80202f82:	7fbc                	ld	a5,120(a5)
    80202f84:	a835                	j	80202fc0 <getParameter+0x9a>
        case 2:
            return p->trapFrame->a2;
    80202f86:	fe843783          	ld	a5,-24(s0)
    80202f8a:	779c                	ld	a5,40(a5)
    80202f8c:	63dc                	ld	a5,128(a5)
    80202f8e:	a80d                	j	80202fc0 <getParameter+0x9a>
        case 3:
            return p->trapFrame->a3;
    80202f90:	fe843783          	ld	a5,-24(s0)
    80202f94:	779c                	ld	a5,40(a5)
    80202f96:	67dc                	ld	a5,136(a5)
    80202f98:	a025                	j	80202fc0 <getParameter+0x9a>
        case 4:
            return p->trapFrame->a4;
    80202f9a:	fe843783          	ld	a5,-24(s0)
    80202f9e:	779c                	ld	a5,40(a5)
    80202fa0:	6bdc                	ld	a5,144(a5)
    80202fa2:	a839                	j	80202fc0 <getParameter+0x9a>
        case 5:
            return p->trapFrame->a5;
    80202fa4:	fe843783          	ld	a5,-24(s0)
    80202fa8:	779c                	ld	a5,40(a5)
    80202faa:	6fdc                	ld	a5,152(a5)
    80202fac:	a811                	j	80202fc0 <getParameter+0x9a>
    }
    panic("getParameter");
    80202fae:	00008517          	auipc	a0,0x8
    80202fb2:	34a50513          	addi	a0,a0,842 # 8020b2f8 <etext+0x2f8>
    80202fb6:	00000097          	auipc	ra,0x0
    80202fba:	b4e080e7          	jalr	-1202(ra) # 80202b04 <panic>
    return 0;
    80202fbe:	4781                	li	a5,0
}
    80202fc0:	853e                	mv	a0,a5
    80202fc2:	70a2                	ld	ra,40(sp)
    80202fc4:	7402                	ld	s0,32(sp)
    80202fc6:	6145                	addi	sp,sp,48
    80202fc8:	8082                	ret

0000000080202fca <sys_getcwd>:

uint64_t
sys_getcwd(void) {
    80202fca:	7179                	addi	sp,sp,-48
    80202fcc:	f406                	sd	ra,40(sp)
    80202fce:	f022                	sd	s0,32(sp)
    80202fd0:	1800                	addi	s0,sp,48
    char* buf = (char*)getParameter(0);
    80202fd2:	4501                	li	a0,0
    80202fd4:	00000097          	auipc	ra,0x0
    80202fd8:	f52080e7          	jalr	-174(ra) # 80202f26 <getParameter>
    80202fdc:	87aa                	mv	a5,a0
    80202fde:	fef43423          	sd	a5,-24(s0)
    size_t size = (size_t)getParameter(1);
    80202fe2:	4505                	li	a0,1
    80202fe4:	00000097          	auipc	ra,0x0
    80202fe8:	f42080e7          	jalr	-190(ra) # 80202f26 <getParameter>
    80202fec:	fea43023          	sd	a0,-32(s0)
    char* cwd = sysfile_getcwd(buf, size);
    80202ff0:	fe043583          	ld	a1,-32(s0)
    80202ff4:	fe843503          	ld	a0,-24(s0)
    80202ff8:	00005097          	auipc	ra,0x5
    80202ffc:	5c4080e7          	jalr	1476(ra) # 802085bc <sysfile_getcwd>
    80203000:	fca43c23          	sd	a0,-40(s0)
    return (uint64_t)cwd;
    80203004:	fd843783          	ld	a5,-40(s0)
}
    80203008:	853e                	mv	a0,a5
    8020300a:	70a2                	ld	ra,40(sp)
    8020300c:	7402                	ld	s0,32(sp)
    8020300e:	6145                	addi	sp,sp,48
    80203010:	8082                	ret

0000000080203012 <sys_dup>:

uint64_t
sys_dup(void) {
    80203012:	1101                	addi	sp,sp,-32
    80203014:	ec06                	sd	ra,24(sp)
    80203016:	e822                	sd	s0,16(sp)
    80203018:	1000                	addi	s0,sp,32
    int fd = (int)getParameter(0);
    8020301a:	4501                	li	a0,0
    8020301c:	00000097          	auipc	ra,0x0
    80203020:	f0a080e7          	jalr	-246(ra) # 80202f26 <getParameter>
    80203024:	87aa                	mv	a5,a0
    80203026:	fef42623          	sw	a5,-20(s0)
    return (uint64_t)sysfile_dup(fd);
    8020302a:	fec42783          	lw	a5,-20(s0)
    8020302e:	853e                	mv	a0,a5
    80203030:	00005097          	auipc	ra,0x5
    80203034:	6f4080e7          	jalr	1780(ra) # 80208724 <sysfile_dup>
    80203038:	87aa                	mv	a5,a0
}
    8020303a:	853e                	mv	a0,a5
    8020303c:	60e2                	ld	ra,24(sp)
    8020303e:	6442                	ld	s0,16(sp)
    80203040:	6105                	addi	sp,sp,32
    80203042:	8082                	ret

0000000080203044 <sys_dup3>:

uint64_t
sys_dup3(void) {}
    80203044:	1141                	addi	sp,sp,-16
    80203046:	e422                	sd	s0,8(sp)
    80203048:	0800                	addi	s0,sp,16
    8020304a:	0001                	nop
    8020304c:	853e                	mv	a0,a5
    8020304e:	6422                	ld	s0,8(sp)
    80203050:	0141                	addi	sp,sp,16
    80203052:	8082                	ret

0000000080203054 <sys_mkdirat>:

uint64_t
sys_mkdirat(void) {}  // TODO: argument
    80203054:	1141                	addi	sp,sp,-16
    80203056:	e422                	sd	s0,8(sp)
    80203058:	0800                	addi	s0,sp,16
    8020305a:	0001                	nop
    8020305c:	853e                	mv	a0,a5
    8020305e:	6422                	ld	s0,8(sp)
    80203060:	0141                	addi	sp,sp,16
    80203062:	8082                	ret

0000000080203064 <sys_unlinkat>:

uint64_t
sys_unlinkat(void) {}  // TODO: argument
    80203064:	1141                	addi	sp,sp,-16
    80203066:	e422                	sd	s0,8(sp)
    80203068:	0800                	addi	s0,sp,16
    8020306a:	0001                	nop
    8020306c:	853e                	mv	a0,a5
    8020306e:	6422                	ld	s0,8(sp)
    80203070:	0141                	addi	sp,sp,16
    80203072:	8082                	ret

0000000080203074 <sys_linkat>:
uint64_t
sys_linkat(void) {}  // TODDO: argument
    80203074:	1141                	addi	sp,sp,-16
    80203076:	e422                	sd	s0,8(sp)
    80203078:	0800                	addi	s0,sp,16
    8020307a:	0001                	nop
    8020307c:	853e                	mv	a0,a5
    8020307e:	6422                	ld	s0,8(sp)
    80203080:	0141                	addi	sp,sp,16
    80203082:	8082                	ret

0000000080203084 <sys_umount2>:

uint64_t
sys_umount2(void) {
    80203084:	1101                	addi	sp,sp,-32
    80203086:	ec06                	sd	ra,24(sp)
    80203088:	e822                	sd	s0,16(sp)
    8020308a:	1000                	addi	s0,sp,32
    char* special = (char*)getParameter(0);
    8020308c:	4501                	li	a0,0
    8020308e:	00000097          	auipc	ra,0x0
    80203092:	e98080e7          	jalr	-360(ra) # 80202f26 <getParameter>
    80203096:	87aa                	mv	a5,a0
    80203098:	fef43423          	sd	a5,-24(s0)
    uint32_t flag = (uint32_t)getParameter(1);
    8020309c:	4505                	li	a0,1
    8020309e:	00000097          	auipc	ra,0x0
    802030a2:	e88080e7          	jalr	-376(ra) # 80202f26 <getParameter>
    802030a6:	87aa                	mv	a5,a0
    802030a8:	fef42223          	sw	a5,-28(s0)
    return (uint64_t)sys_unmount(special, flag);
    802030ac:	fe442783          	lw	a5,-28(s0)
    802030b0:	85be                	mv	a1,a5
    802030b2:	fe843503          	ld	a0,-24(s0)
    802030b6:	00006097          	auipc	ra,0x6
    802030ba:	878080e7          	jalr	-1928(ra) # 8020892e <sys_unmount>
    802030be:	87aa                	mv	a5,a0
}
    802030c0:	853e                	mv	a0,a5
    802030c2:	60e2                	ld	ra,24(sp)
    802030c4:	6442                	ld	s0,16(sp)
    802030c6:	6105                	addi	sp,sp,32
    802030c8:	8082                	ret

00000000802030ca <sys_mount1>:

uint64_t
sys_mount1(void) {
    802030ca:	7139                	addi	sp,sp,-64
    802030cc:	fc06                	sd	ra,56(sp)
    802030ce:	f822                	sd	s0,48(sp)
    802030d0:	0080                	addi	s0,sp,64
    char* special = (char*)getParameter(0);
    802030d2:	4501                	li	a0,0
    802030d4:	00000097          	auipc	ra,0x0
    802030d8:	e52080e7          	jalr	-430(ra) # 80202f26 <getParameter>
    802030dc:	87aa                	mv	a5,a0
    802030de:	fef43423          	sd	a5,-24(s0)
    char* dir = (char*)getParameter(1);
    802030e2:	4505                	li	a0,1
    802030e4:	00000097          	auipc	ra,0x0
    802030e8:	e42080e7          	jalr	-446(ra) # 80202f26 <getParameter>
    802030ec:	87aa                	mv	a5,a0
    802030ee:	fef43023          	sd	a5,-32(s0)
    char* fstype = (char*)getParameter(2);
    802030f2:	4509                	li	a0,2
    802030f4:	00000097          	auipc	ra,0x0
    802030f8:	e32080e7          	jalr	-462(ra) # 80202f26 <getParameter>
    802030fc:	87aa                	mv	a5,a0
    802030fe:	fcf43c23          	sd	a5,-40(s0)
    uint32_t flag = (uint32_t)getParameter(3);
    80203102:	450d                	li	a0,3
    80203104:	00000097          	auipc	ra,0x0
    80203108:	e22080e7          	jalr	-478(ra) # 80202f26 <getParameter>
    8020310c:	87aa                	mv	a5,a0
    8020310e:	fcf42a23          	sw	a5,-44(s0)
    void* data = (void*)getParameter(4);
    80203112:	4511                	li	a0,4
    80203114:	00000097          	auipc	ra,0x0
    80203118:	e12080e7          	jalr	-494(ra) # 80202f26 <getParameter>
    8020311c:	87aa                	mv	a5,a0
    8020311e:	fcf43423          	sd	a5,-56(s0)
    return (uint64_t)sys_mount(special, dir, fstype, flag, data);
    80203122:	fd442783          	lw	a5,-44(s0)
    80203126:	fc843703          	ld	a4,-56(s0)
    8020312a:	86be                	mv	a3,a5
    8020312c:	fd843603          	ld	a2,-40(s0)
    80203130:	fe043583          	ld	a1,-32(s0)
    80203134:	fe843503          	ld	a0,-24(s0)
    80203138:	00005097          	auipc	ra,0x5
    8020313c:	7d0080e7          	jalr	2000(ra) # 80208908 <sys_mount>
    80203140:	87aa                	mv	a5,a0
}
    80203142:	853e                	mv	a0,a5
    80203144:	70e2                	ld	ra,56(sp)
    80203146:	7442                	ld	s0,48(sp)
    80203148:	6121                	addi	sp,sp,64
    8020314a:	8082                	ret

000000008020314c <sys_chdir>:

uint64_t
sys_chdir(void) {
    8020314c:	1101                	addi	sp,sp,-32
    8020314e:	ec06                	sd	ra,24(sp)
    80203150:	e822                	sd	s0,16(sp)
    80203152:	1000                	addi	s0,sp,32
    char* name = (char*)getParameter(0);
    80203154:	4501                	li	a0,0
    80203156:	00000097          	auipc	ra,0x0
    8020315a:	dd0080e7          	jalr	-560(ra) # 80202f26 <getParameter>
    8020315e:	87aa                	mv	a5,a0
    80203160:	fef43423          	sd	a5,-24(s0)
    return (uint64_t)sysfile_chdir(name);
    80203164:	fe843503          	ld	a0,-24(s0)
    80203168:	00005097          	auipc	ra,0x5
    8020316c:	0be080e7          	jalr	190(ra) # 80208226 <sysfile_chdir>
    80203170:	87aa                	mv	a5,a0
}
    80203172:	853e                	mv	a0,a5
    80203174:	60e2                	ld	ra,24(sp)
    80203176:	6442                	ld	s0,16(sp)
    80203178:	6105                	addi	sp,sp,32
    8020317a:	8082                	ret

000000008020317c <sys_openat>:
//     char *path = (char *)getParameter(2);
//     uint32_t flags = (uint32_t)getParameter(3);

// }
uint64_t
sys_openat(void) {
    8020317c:	7179                	addi	sp,sp,-48
    8020317e:	f406                	sd	ra,40(sp)
    80203180:	f022                	sd	s0,32(sp)
    80203182:	1800                	addi	s0,sp,48
    int fd = (int)getParameter(0);
    80203184:	4501                	li	a0,0
    80203186:	00000097          	auipc	ra,0x0
    8020318a:	da0080e7          	jalr	-608(ra) # 80202f26 <getParameter>
    8020318e:	87aa                	mv	a5,a0
    80203190:	fef42623          	sw	a5,-20(s0)
    const char* __path = (const char*)getParameter(1);
    80203194:	4505                	li	a0,1
    80203196:	00000097          	auipc	ra,0x0
    8020319a:	d90080e7          	jalr	-624(ra) # 80202f26 <getParameter>
    8020319e:	87aa                	mv	a5,a0
    802031a0:	fef43023          	sd	a5,-32(s0)
    uint32_t flags = (uint32_t)getParameter(2);
    802031a4:	4509                	li	a0,2
    802031a6:	00000097          	auipc	ra,0x0
    802031aa:	d80080e7          	jalr	-640(ra) # 80202f26 <getParameter>
    802031ae:	87aa                	mv	a5,a0
    802031b0:	fcf42e23          	sw	a5,-36(s0)
    return (uint64_t)sysfile_open(fd, __path, flags);
    802031b4:	fdc42703          	lw	a4,-36(s0)
    802031b8:	fec42783          	lw	a5,-20(s0)
    802031bc:	863a                	mv	a2,a4
    802031be:	fe043583          	ld	a1,-32(s0)
    802031c2:	853e                	mv	a0,a5
    802031c4:	00005097          	auipc	ra,0x5
    802031c8:	9f0080e7          	jalr	-1552(ra) # 80207bb4 <sysfile_open>
    802031cc:	87aa                	mv	a5,a0
}
    802031ce:	853e                	mv	a0,a5
    802031d0:	70a2                	ld	ra,40(sp)
    802031d2:	7402                	ld	s0,32(sp)
    802031d4:	6145                	addi	sp,sp,48
    802031d6:	8082                	ret

00000000802031d8 <sys_close>:

uint64_t
sys_close(void) {
    802031d8:	1101                	addi	sp,sp,-32
    802031da:	ec06                	sd	ra,24(sp)
    802031dc:	e822                	sd	s0,16(sp)
    802031de:	1000                	addi	s0,sp,32
    int fd = (int)getParameter(0);
    802031e0:	4501                	li	a0,0
    802031e2:	00000097          	auipc	ra,0x0
    802031e6:	d44080e7          	jalr	-700(ra) # 80202f26 <getParameter>
    802031ea:	87aa                	mv	a5,a0
    802031ec:	fef42623          	sw	a5,-20(s0)
    return (uint64_t)sysfile_close(fd);
    802031f0:	fec42783          	lw	a5,-20(s0)
    802031f4:	853e                	mv	a0,a5
    802031f6:	00005097          	auipc	ra,0x5
    802031fa:	c80080e7          	jalr	-896(ra) # 80207e76 <sysfile_close>
    802031fe:	87aa                	mv	a5,a0
}
    80203200:	853e                	mv	a0,a5
    80203202:	60e2                	ld	ra,24(sp)
    80203204:	6442                	ld	s0,16(sp)
    80203206:	6105                	addi	sp,sp,32
    80203208:	8082                	ret

000000008020320a <sys_pipe2>:

uint64_t
sys_pipe2(void) {}  // TODO: argument
    8020320a:	1141                	addi	sp,sp,-16
    8020320c:	e422                	sd	s0,8(sp)
    8020320e:	0800                	addi	s0,sp,16
    80203210:	0001                	nop
    80203212:	853e                	mv	a0,a5
    80203214:	6422                	ld	s0,8(sp)
    80203216:	0141                	addi	sp,sp,16
    80203218:	8082                	ret

000000008020321a <sys_getdents64>:

uint64_t
sys_getdents64(void) {
    8020321a:	1101                	addi	sp,sp,-32
    8020321c:	ec06                	sd	ra,24(sp)
    8020321e:	e822                	sd	s0,16(sp)
    80203220:	1000                	addi	s0,sp,32
    int fd = (int)getParameter(0);
    80203222:	4501                	li	a0,0
    80203224:	00000097          	auipc	ra,0x0
    80203228:	d02080e7          	jalr	-766(ra) # 80202f26 <getParameter>
    8020322c:	87aa                	mv	a5,a0
    8020322e:	fef42623          	sw	a5,-20(s0)
    dirent_t* __direntp = (dirent_t*)getParameter(1);
    80203232:	4505                	li	a0,1
    80203234:	00000097          	auipc	ra,0x0
    80203238:	cf2080e7          	jalr	-782(ra) # 80202f26 <getParameter>
    8020323c:	87aa                	mv	a5,a0
    8020323e:	fef43023          	sd	a5,-32(s0)
    return (uint64_t)sysfile_getDirEntry(fd, __direntp);
    80203242:	fec42783          	lw	a5,-20(s0)
    80203246:	fe043583          	ld	a1,-32(s0)
    8020324a:	853e                	mv	a0,a5
    8020324c:	00005097          	auipc	ra,0x5
    80203250:	46e080e7          	jalr	1134(ra) # 802086ba <sysfile_getDirEntry>
    80203254:	87aa                	mv	a5,a0
}
    80203256:	853e                	mv	a0,a5
    80203258:	60e2                	ld	ra,24(sp)
    8020325a:	6442                	ld	s0,16(sp)
    8020325c:	6105                	addi	sp,sp,32
    8020325e:	8082                	ret

0000000080203260 <sys_read>:

uint64_t
sys_read(void) {
    80203260:	7179                	addi	sp,sp,-48
    80203262:	f406                	sd	ra,40(sp)
    80203264:	f022                	sd	s0,32(sp)
    80203266:	1800                	addi	s0,sp,48
    int fd = (int)getParameter(0);
    80203268:	4501                	li	a0,0
    8020326a:	00000097          	auipc	ra,0x0
    8020326e:	cbc080e7          	jalr	-836(ra) # 80202f26 <getParameter>
    80203272:	87aa                	mv	a5,a0
    80203274:	fef42623          	sw	a5,-20(s0)
    void* buf = (void*)getParameter(1);
    80203278:	4505                	li	a0,1
    8020327a:	00000097          	auipc	ra,0x0
    8020327e:	cac080e7          	jalr	-852(ra) # 80202f26 <getParameter>
    80203282:	87aa                	mv	a5,a0
    80203284:	fef43023          	sd	a5,-32(s0)
    size_t count = (size_t)getParameter(2);
    80203288:	4509                	li	a0,2
    8020328a:	00000097          	auipc	ra,0x0
    8020328e:	c9c080e7          	jalr	-868(ra) # 80202f26 <getParameter>
    80203292:	fca43c23          	sd	a0,-40(s0)
    return (uint64_t)sysfile_read(fd, buf, count);
    80203296:	fec42783          	lw	a5,-20(s0)
    8020329a:	fd843603          	ld	a2,-40(s0)
    8020329e:	fe043583          	ld	a1,-32(s0)
    802032a2:	853e                	mv	a0,a5
    802032a4:	00005097          	auipc	ra,0x5
    802032a8:	c2a080e7          	jalr	-982(ra) # 80207ece <sysfile_read>
    802032ac:	87aa                	mv	a5,a0
}
    802032ae:	853e                	mv	a0,a5
    802032b0:	70a2                	ld	ra,40(sp)
    802032b2:	7402                	ld	s0,32(sp)
    802032b4:	6145                	addi	sp,sp,48
    802032b6:	8082                	ret

00000000802032b8 <sys_write>:

uint64_t
sys_write(void)  // pay attention to ret: byte to write
{
    802032b8:	7179                	addi	sp,sp,-48
    802032ba:	f406                	sd	ra,40(sp)
    802032bc:	f022                	sd	s0,32(sp)
    802032be:	1800                	addi	s0,sp,48
    int fd = (int)getParameter(0);
    802032c0:	4501                	li	a0,0
    802032c2:	00000097          	auipc	ra,0x0
    802032c6:	c64080e7          	jalr	-924(ra) # 80202f26 <getParameter>
    802032ca:	87aa                	mv	a5,a0
    802032cc:	fef42623          	sw	a5,-20(s0)
    void* buf = (void*)getParameter(1);
    802032d0:	4505                	li	a0,1
    802032d2:	00000097          	auipc	ra,0x0
    802032d6:	c54080e7          	jalr	-940(ra) # 80202f26 <getParameter>
    802032da:	87aa                	mv	a5,a0
    802032dc:	fef43023          	sd	a5,-32(s0)
    size_t count = (size_t)getParameter(2);
    802032e0:	4509                	li	a0,2
    802032e2:	00000097          	auipc	ra,0x0
    802032e6:	c44080e7          	jalr	-956(ra) # 80202f26 <getParameter>
    802032ea:	fca43c23          	sd	a0,-40(s0)
    return (uint64_t)sysfile_write(fd, buf, count);
    802032ee:	fec42783          	lw	a5,-20(s0)
    802032f2:	fd843603          	ld	a2,-40(s0)
    802032f6:	fe043583          	ld	a1,-32(s0)
    802032fa:	853e                	mv	a0,a5
    802032fc:	00005097          	auipc	ra,0x5
    80203300:	c80080e7          	jalr	-896(ra) # 80207f7c <sysfile_write>
    80203304:	87aa                	mv	a5,a0
}
    80203306:	853e                	mv	a0,a5
    80203308:	70a2                	ld	ra,40(sp)
    8020330a:	7402                	ld	s0,32(sp)
    8020330c:	6145                	addi	sp,sp,48
    8020330e:	8082                	ret

0000000080203310 <sys_fstat>:

uint64_t
sys_fstat(void) {
    80203310:	1101                	addi	sp,sp,-32
    80203312:	ec06                	sd	ra,24(sp)
    80203314:	e822                	sd	s0,16(sp)
    80203316:	1000                	addi	s0,sp,32
    int fd = (int)getParameter(0);
    80203318:	4501                	li	a0,0
    8020331a:	00000097          	auipc	ra,0x0
    8020331e:	c0c080e7          	jalr	-1012(ra) # 80202f26 <getParameter>
    80203322:	87aa                	mv	a5,a0
    80203324:	fef42623          	sw	a5,-20(s0)
    stat_t* stat = (stat_t*)getParameter(1);
    80203328:	4505                	li	a0,1
    8020332a:	00000097          	auipc	ra,0x0
    8020332e:	bfc080e7          	jalr	-1028(ra) # 80202f26 <getParameter>
    80203332:	87aa                	mv	a5,a0
    80203334:	fef43023          	sd	a5,-32(s0)
    return (uint64_t)sysfile_fstat(fd, stat);
    80203338:	fec42783          	lw	a5,-20(s0)
    8020333c:	fe043583          	ld	a1,-32(s0)
    80203340:	853e                	mv	a0,a5
    80203342:	00005097          	auipc	ra,0x5
    80203346:	de4080e7          	jalr	-540(ra) # 80208126 <sysfile_fstat>
    8020334a:	87aa                	mv	a5,a0
}
    8020334c:	853e                	mv	a0,a5
    8020334e:	60e2                	ld	ra,24(sp)
    80203350:	6442                	ld	s0,16(sp)
    80203352:	6105                	addi	sp,sp,32
    80203354:	8082                	ret

0000000080203356 <sys_exit>:

uint64_t
sys_exit(void) {
    80203356:	1101                	addi	sp,sp,-32
    80203358:	ec06                	sd	ra,24(sp)
    8020335a:	e822                	sd	s0,16(sp)
    8020335c:	1000                	addi	s0,sp,32
    int ec = (int)getParameter(0);
    8020335e:	4501                	li	a0,0
    80203360:	00000097          	auipc	ra,0x0
    80203364:	bc6080e7          	jalr	-1082(ra) # 80202f26 <getParameter>
    80203368:	87aa                	mv	a5,a0
    8020336a:	fef42623          	sw	a5,-20(s0)
    sysproc_exit(ec);
    8020336e:	fec42783          	lw	a5,-20(s0)
    80203372:	853e                	mv	a0,a5
    80203374:	00001097          	auipc	ra,0x1
    80203378:	ce0080e7          	jalr	-800(ra) # 80204054 <sysproc_exit>
    return 0;
    8020337c:	4781                	li	a5,0
}
    8020337e:	853e                	mv	a0,a5
    80203380:	60e2                	ld	ra,24(sp)
    80203382:	6442                	ld	s0,16(sp)
    80203384:	6105                	addi	sp,sp,32
    80203386:	8082                	ret

0000000080203388 <sys_getpid>:

uint64_t
sys_getpid(void) {
    80203388:	1141                	addi	sp,sp,-16
    8020338a:	e406                	sd	ra,8(sp)
    8020338c:	e022                	sd	s0,0(sp)
    8020338e:	0800                	addi	s0,sp,16
    return (uint64_t)sysproc_getpid();
    80203390:	00001097          	auipc	ra,0x1
    80203394:	e32080e7          	jalr	-462(ra) # 802041c2 <sysproc_getpid>
    80203398:	87aa                	mv	a5,a0
}
    8020339a:	853e                	mv	a0,a5
    8020339c:	60a2                	ld	ra,8(sp)
    8020339e:	6402                	ld	s0,0(sp)
    802033a0:	0141                	addi	sp,sp,16
    802033a2:	8082                	ret

00000000802033a4 <sys_getppid>:

uint64_t
sys_getppid(void) {
    802033a4:	1141                	addi	sp,sp,-16
    802033a6:	e406                	sd	ra,8(sp)
    802033a8:	e022                	sd	s0,0(sp)
    802033aa:	0800                	addi	s0,sp,16
    return (uint64_t)sysproc_getppid();
    802033ac:	00001097          	auipc	ra,0x1
    802033b0:	e34080e7          	jalr	-460(ra) # 802041e0 <sysproc_getppid>
    802033b4:	87aa                	mv	a5,a0
}
    802033b6:	853e                	mv	a0,a5
    802033b8:	60a2                	ld	ra,8(sp)
    802033ba:	6402                	ld	s0,0(sp)
    802033bc:	0141                	addi	sp,sp,16
    802033be:	8082                	ret

00000000802033c0 <sys_clone>:

uint64_t
sys_clone(void) {
    802033c0:	7139                	addi	sp,sp,-64
    802033c2:	fc06                	sd	ra,56(sp)
    802033c4:	f822                	sd	s0,48(sp)
    802033c6:	0080                	addi	s0,sp,64
    uint64_t flag = (uint64_t)getParameter(0);
    802033c8:	4501                	li	a0,0
    802033ca:	00000097          	auipc	ra,0x0
    802033ce:	b5c080e7          	jalr	-1188(ra) # 80202f26 <getParameter>
    802033d2:	fea43423          	sd	a0,-24(s0)
    void* stack = (void*)getParameter(1);
    802033d6:	4505                	li	a0,1
    802033d8:	00000097          	auipc	ra,0x0
    802033dc:	b4e080e7          	jalr	-1202(ra) # 80202f26 <getParameter>
    802033e0:	87aa                	mv	a5,a0
    802033e2:	fef43023          	sd	a5,-32(s0)
    pid_t ptid = (pid_t)getParameter(2);
    802033e6:	4509                	li	a0,2
    802033e8:	00000097          	auipc	ra,0x0
    802033ec:	b3e080e7          	jalr	-1218(ra) # 80202f26 <getParameter>
    802033f0:	87aa                	mv	a5,a0
    802033f2:	fcf42e23          	sw	a5,-36(s0)
    uint64_t tls = (uint64_t)getParameter(3);
    802033f6:	450d                	li	a0,3
    802033f8:	00000097          	auipc	ra,0x0
    802033fc:	b2e080e7          	jalr	-1234(ra) # 80202f26 <getParameter>
    80203400:	fca43823          	sd	a0,-48(s0)
    pid_t ctid = (pid_t)getParameter(4);
    80203404:	4511                	li	a0,4
    80203406:	00000097          	auipc	ra,0x0
    8020340a:	b20080e7          	jalr	-1248(ra) # 80202f26 <getParameter>
    8020340e:	87aa                	mv	a5,a0
    80203410:	fcf42623          	sw	a5,-52(s0)
    return (uint64_t)sysproc_clone(flag, stack, ptid, tls, ctid);
    80203414:	fcc42703          	lw	a4,-52(s0)
    80203418:	fdc42783          	lw	a5,-36(s0)
    8020341c:	fd043683          	ld	a3,-48(s0)
    80203420:	863e                	mv	a2,a5
    80203422:	fe043583          	ld	a1,-32(s0)
    80203426:	fe843503          	ld	a0,-24(s0)
    8020342a:	00001097          	auipc	ra,0x1
    8020342e:	dec080e7          	jalr	-532(ra) # 80204216 <sysproc_clone>
    80203432:	87aa                	mv	a5,a0
}
    80203434:	853e                	mv	a0,a5
    80203436:	70e2                	ld	ra,56(sp)
    80203438:	7442                	ld	s0,48(sp)
    8020343a:	6121                	addi	sp,sp,64
    8020343c:	8082                	ret

000000008020343e <sys_execve>:
uint64_t
sys_execve(void) {
    8020343e:	7179                	addi	sp,sp,-48
    80203440:	f406                	sd	ra,40(sp)
    80203442:	f022                	sd	s0,32(sp)
    80203444:	1800                	addi	s0,sp,48
    char* path = (char*)getParameter(0);
    80203446:	4501                	li	a0,0
    80203448:	00000097          	auipc	ra,0x0
    8020344c:	ade080e7          	jalr	-1314(ra) # 80202f26 <getParameter>
    80203450:	87aa                	mv	a5,a0
    80203452:	fef43423          	sd	a5,-24(s0)
    char* argv = (char*)getParameter(1);
    80203456:	4505                	li	a0,1
    80203458:	00000097          	auipc	ra,0x0
    8020345c:	ace080e7          	jalr	-1330(ra) # 80202f26 <getParameter>
    80203460:	87aa                	mv	a5,a0
    80203462:	fef43023          	sd	a5,-32(s0)
    char* envp = (char*)getParameter(2);
    80203466:	4509                	li	a0,2
    80203468:	00000097          	auipc	ra,0x0
    8020346c:	abe080e7          	jalr	-1346(ra) # 80202f26 <getParameter>
    80203470:	87aa                	mv	a5,a0
    80203472:	fcf43c23          	sd	a5,-40(s0)
    return (uint64_t)sysproc_execve(path, argv, envp);
    80203476:	fd843603          	ld	a2,-40(s0)
    8020347a:	fe043583          	ld	a1,-32(s0)
    8020347e:	fe843503          	ld	a0,-24(s0)
    80203482:	00001097          	auipc	ra,0x1
    80203486:	dd2080e7          	jalr	-558(ra) # 80204254 <sysproc_execve>
    8020348a:	87aa                	mv	a5,a0
}
    8020348c:	853e                	mv	a0,a5
    8020348e:	70a2                	ld	ra,40(sp)
    80203490:	7402                	ld	s0,32(sp)
    80203492:	6145                	addi	sp,sp,48
    80203494:	8082                	ret

0000000080203496 <sys_wait4>:

uint64_t
sys_wait4(void) {
    80203496:	7179                	addi	sp,sp,-48
    80203498:	f406                	sd	ra,40(sp)
    8020349a:	f022                	sd	s0,32(sp)
    8020349c:	1800                	addi	s0,sp,48
    pid_t pid = (pid_t)getParameter(0);
    8020349e:	4501                	li	a0,0
    802034a0:	00000097          	auipc	ra,0x0
    802034a4:	a86080e7          	jalr	-1402(ra) # 80202f26 <getParameter>
    802034a8:	87aa                	mv	a5,a0
    802034aa:	fef42623          	sw	a5,-20(s0)
    int* status = (int*)getParameter(1);
    802034ae:	4505                	li	a0,1
    802034b0:	00000097          	auipc	ra,0x0
    802034b4:	a76080e7          	jalr	-1418(ra) # 80202f26 <getParameter>
    802034b8:	87aa                	mv	a5,a0
    802034ba:	fef43023          	sd	a5,-32(s0)
    int options = (int)getParameter(2);
    802034be:	4509                	li	a0,2
    802034c0:	00000097          	auipc	ra,0x0
    802034c4:	a66080e7          	jalr	-1434(ra) # 80202f26 <getParameter>
    802034c8:	87aa                	mv	a5,a0
    802034ca:	fcf42e23          	sw	a5,-36(s0)
    return (uint64_t)sysproc_wait4(pid, status, options);
    802034ce:	fdc42703          	lw	a4,-36(s0)
    802034d2:	fec42783          	lw	a5,-20(s0)
    802034d6:	863a                	mv	a2,a4
    802034d8:	fe043583          	ld	a1,-32(s0)
    802034dc:	853e                	mv	a0,a5
    802034de:	00001097          	auipc	ra,0x1
    802034e2:	dec080e7          	jalr	-532(ra) # 802042ca <sysproc_wait4>
    802034e6:	87aa                	mv	a5,a0
}
    802034e8:	853e                	mv	a0,a5
    802034ea:	70a2                	ld	ra,40(sp)
    802034ec:	7402                	ld	s0,32(sp)
    802034ee:	6145                	addi	sp,sp,48
    802034f0:	8082                	ret

00000000802034f2 <sys_brk>:

uint64_t
sys_brk(void) {
    802034f2:	1101                	addi	sp,sp,-32
    802034f4:	ec06                	sd	ra,24(sp)
    802034f6:	e822                	sd	s0,16(sp)
    802034f8:	1000                	addi	s0,sp,32
    address_t brk = (address_t)getParameter(0);
    802034fa:	4501                	li	a0,0
    802034fc:	00000097          	auipc	ra,0x0
    80203500:	a2a080e7          	jalr	-1494(ra) # 80202f26 <getParameter>
    80203504:	fea43423          	sd	a0,-24(s0)
    return (uint64_t)sysmm_brk(brk);
    80203508:	fe843503          	ld	a0,-24(s0)
    8020350c:	00001097          	auipc	ra,0x1
    80203510:	e84080e7          	jalr	-380(ra) # 80204390 <sysmm_brk>
    80203514:	87aa                	mv	a5,a0
}
    80203516:	853e                	mv	a0,a5
    80203518:	60e2                	ld	ra,24(sp)
    8020351a:	6442                	ld	s0,16(sp)
    8020351c:	6105                	addi	sp,sp,32
    8020351e:	8082                	ret

0000000080203520 <sys_munmap>:

uint64_t
sys_munmap(void) {
    80203520:	1101                	addi	sp,sp,-32
    80203522:	ec06                	sd	ra,24(sp)
    80203524:	e822                	sd	s0,16(sp)
    80203526:	1000                	addi	s0,sp,32
    void* start = (void*)getParameter(0);
    80203528:	4501                	li	a0,0
    8020352a:	00000097          	auipc	ra,0x0
    8020352e:	9fc080e7          	jalr	-1540(ra) # 80202f26 <getParameter>
    80203532:	87aa                	mv	a5,a0
    80203534:	fef43423          	sd	a5,-24(s0)
    size_t len = (size_t)getParameter(1);
    80203538:	4505                	li	a0,1
    8020353a:	00000097          	auipc	ra,0x0
    8020353e:	9ec080e7          	jalr	-1556(ra) # 80202f26 <getParameter>
    80203542:	fea43023          	sd	a0,-32(s0)
    return (uint64_t)sysmm_munmap(start, len);
    80203546:	fe043583          	ld	a1,-32(s0)
    8020354a:	fe843503          	ld	a0,-24(s0)
    8020354e:	00001097          	auipc	ra,0x1
    80203552:	edc080e7          	jalr	-292(ra) # 8020442a <sysmm_munmap>
    80203556:	87aa                	mv	a5,a0
}
    80203558:	853e                	mv	a0,a5
    8020355a:	60e2                	ld	ra,24(sp)
    8020355c:	6442                	ld	s0,16(sp)
    8020355e:	6105                	addi	sp,sp,32
    80203560:	8082                	ret

0000000080203562 <sys_mmap>:

uint64_t
sys_mmap(void) {
    80203562:	7139                	addi	sp,sp,-64
    80203564:	fc06                	sd	ra,56(sp)
    80203566:	f822                	sd	s0,48(sp)
    80203568:	0080                	addi	s0,sp,64
    void* start = (void*)getParameter(0);
    8020356a:	4501                	li	a0,0
    8020356c:	00000097          	auipc	ra,0x0
    80203570:	9ba080e7          	jalr	-1606(ra) # 80202f26 <getParameter>
    80203574:	87aa                	mv	a5,a0
    80203576:	fef43423          	sd	a5,-24(s0)
    size_t len = (size_t)getParameter(1);
    8020357a:	4505                	li	a0,1
    8020357c:	00000097          	auipc	ra,0x0
    80203580:	9aa080e7          	jalr	-1622(ra) # 80202f26 <getParameter>
    80203584:	fea43023          	sd	a0,-32(s0)
    int prot = (int)getParameter(2);
    80203588:	4509                	li	a0,2
    8020358a:	00000097          	auipc	ra,0x0
    8020358e:	99c080e7          	jalr	-1636(ra) # 80202f26 <getParameter>
    80203592:	87aa                	mv	a5,a0
    80203594:	fcf42e23          	sw	a5,-36(s0)
    int flags = (int)getParameter(3);
    80203598:	450d                	li	a0,3
    8020359a:	00000097          	auipc	ra,0x0
    8020359e:	98c080e7          	jalr	-1652(ra) # 80202f26 <getParameter>
    802035a2:	87aa                	mv	a5,a0
    802035a4:	fcf42c23          	sw	a5,-40(s0)
    int fd = (int)getParameter(4);
    802035a8:	4511                	li	a0,4
    802035aa:	00000097          	auipc	ra,0x0
    802035ae:	97c080e7          	jalr	-1668(ra) # 80202f26 <getParameter>
    802035b2:	87aa                	mv	a5,a0
    802035b4:	fcf42a23          	sw	a5,-44(s0)
    uint64_t off = (uint64_t)getParameter(5);
    802035b8:	4515                	li	a0,5
    802035ba:	00000097          	auipc	ra,0x0
    802035be:	96c080e7          	jalr	-1684(ra) # 80202f26 <getParameter>
    802035c2:	fca43423          	sd	a0,-56(s0)
    return (uint64_t)sysmm_mmap(start, len, prot, flags, fd, off);
    802035c6:	fd442703          	lw	a4,-44(s0)
    802035ca:	fd842683          	lw	a3,-40(s0)
    802035ce:	fdc42603          	lw	a2,-36(s0)
    802035d2:	fc843783          	ld	a5,-56(s0)
    802035d6:	fe043583          	ld	a1,-32(s0)
    802035da:	fe843503          	ld	a0,-24(s0)
    802035de:	00001097          	auipc	ra,0x1
    802035e2:	e8a080e7          	jalr	-374(ra) # 80204468 <sysmm_mmap>
    802035e6:	87aa                	mv	a5,a0
}
    802035e8:	853e                	mv	a0,a5
    802035ea:	70e2                	ld	ra,56(sp)
    802035ec:	7442                	ld	s0,48(sp)
    802035ee:	6121                	addi	sp,sp,64
    802035f0:	8082                	ret

00000000802035f2 <sys_nanosleep>:

uint64_t
sys_nanosleep(void) {}  // TODO
    802035f2:	1141                	addi	sp,sp,-16
    802035f4:	e422                	sd	s0,8(sp)
    802035f6:	0800                	addi	s0,sp,16
    802035f8:	0001                	nop
    802035fa:	853e                	mv	a0,a5
    802035fc:	6422                	ld	s0,8(sp)
    802035fe:	0141                	addi	sp,sp,16
    80203600:	8082                	ret

0000000080203602 <sys_sched_yield>:

uint64_t
sys_sched_yield(void) {
    80203602:	1141                	addi	sp,sp,-16
    80203604:	e406                	sd	ra,8(sp)
    80203606:	e022                	sd	s0,0(sp)
    80203608:	0800                	addi	s0,sp,16
    yield();
    8020360a:	fffff097          	auipc	ra,0xfffff
    8020360e:	c4e080e7          	jalr	-946(ra) # 80202258 <yield>
    return 0;
    80203612:	4781                	li	a5,0
}
    80203614:	853e                	mv	a0,a5
    80203616:	60a2                	ld	ra,8(sp)
    80203618:	6402                	ld	s0,0(sp)
    8020361a:	0141                	addi	sp,sp,16
    8020361c:	8082                	ret

000000008020361e <sys_times>:

address_t
sys_times(void) {
    8020361e:	1101                	addi	sp,sp,-32
    80203620:	ec06                	sd	ra,24(sp)
    80203622:	e822                	sd	s0,16(sp)
    80203624:	1000                	addi	s0,sp,32
    void* mytimes = (void*)getParameter(0);
    80203626:	4501                	li	a0,0
    80203628:	00000097          	auipc	ra,0x0
    8020362c:	8fe080e7          	jalr	-1794(ra) # 80202f26 <getParameter>
    80203630:	87aa                	mv	a5,a0
    80203632:	fef43423          	sd	a5,-24(s0)
    return sysproc_times(mytimes);
    80203636:	fe843503          	ld	a0,-24(s0)
    8020363a:	00001097          	auipc	ra,0x1
    8020363e:	ce0080e7          	jalr	-800(ra) # 8020431a <sysproc_times>
    80203642:	87aa                	mv	a5,a0
}
    80203644:	853e                	mv	a0,a5
    80203646:	60e2                	ld	ra,24(sp)
    80203648:	6442                	ld	s0,16(sp)
    8020364a:	6105                	addi	sp,sp,32
    8020364c:	8082                	ret

000000008020364e <sys_uname>:

uint64_t
sys_uname(void) {
    8020364e:	1101                	addi	sp,sp,-32
    80203650:	ec06                	sd	ra,24(sp)
    80203652:	e822                	sd	s0,16(sp)
    80203654:	1000                	addi	s0,sp,32
    utsname_t* un = (utsname_t*)getParameter(0);
    80203656:	4501                	li	a0,0
    80203658:	00000097          	auipc	ra,0x0
    8020365c:	8ce080e7          	jalr	-1842(ra) # 80202f26 <getParameter>
    80203660:	87aa                	mv	a5,a0
    80203662:	fef43423          	sd	a5,-24(s0)
    memmove(un, &utsname, sizeof(utsname));
    80203666:	18600613          	li	a2,390
    8020366a:	00009597          	auipc	a1,0x9
    8020366e:	99658593          	addi	a1,a1,-1642 # 8020c000 <utsname>
    80203672:	fe843503          	ld	a0,-24(s0)
    80203676:	fffff097          	auipc	ra,0xfffff
    8020367a:	506080e7          	jalr	1286(ra) # 80202b7c <memmove>
    return 0;
    8020367e:	4781                	li	a5,0
}
    80203680:	853e                	mv	a0,a5
    80203682:	60e2                	ld	ra,24(sp)
    80203684:	6442                	ld	s0,16(sp)
    80203686:	6105                	addi	sp,sp,32
    80203688:	8082                	ret

000000008020368a <sys_gettimeofday>:

uint64_t
sys_gettimeofday(void) {
    8020368a:	1141                	addi	sp,sp,-16
    8020368c:	e406                	sd	ra,8(sp)
    8020368e:	e022                	sd	s0,0(sp)
    80203690:	0800                	addi	s0,sp,16
    return r_time();
    80203692:	00000097          	auipc	ra,0x0
    80203696:	87a080e7          	jalr	-1926(ra) # 80202f0c <r_time>
    8020369a:	87aa                	mv	a5,a0
}
    8020369c:	853e                	mv	a0,a5
    8020369e:	60a2                	ld	ra,8(sp)
    802036a0:	6402                	ld	s0,0(sp)
    802036a2:	0141                	addi	sp,sp,16
    802036a4:	8082                	ret

00000000802036a6 <syscall>:
    [SYS_uname] sys_uname,
    [SYS_gettimeofday] sys_gettimeofday,
};

void
syscall(void) {
    802036a6:	7179                	addi	sp,sp,-48
    802036a8:	f406                	sd	ra,40(sp)
    802036aa:	f022                	sd	s0,32(sp)
    802036ac:	ec26                	sd	s1,24(sp)
    802036ae:	1800                	addi	s0,sp,48
    proc_t* p = getCurrentProc();
    802036b0:	ffffe097          	auipc	ra,0xffffe
    802036b4:	51e080e7          	jalr	1310(ra) # 80201bce <getCurrentProc>
    802036b8:	fca43c23          	sd	a0,-40(s0)
    uint64_t syscall_number = p->trapFrame->a7;
    802036bc:	fd843783          	ld	a5,-40(s0)
    802036c0:	779c                	ld	a5,40(a5)
    802036c2:	77dc                	ld	a5,168(a5)
    802036c4:	fcf43823          	sd	a5,-48(s0)
    if ((syscall_number > 0) && (syscalls[syscall_number] != 0)) {
    802036c8:	fd043783          	ld	a5,-48(s0)
    802036cc:	cb9d                	beqz	a5,80203702 <syscall+0x5c>
    802036ce:	00009717          	auipc	a4,0x9
    802036d2:	aba70713          	addi	a4,a4,-1350 # 8020c188 <syscalls>
    802036d6:	fd043783          	ld	a5,-48(s0)
    802036da:	078e                	slli	a5,a5,0x3
    802036dc:	97ba                	add	a5,a5,a4
    802036de:	639c                	ld	a5,0(a5)
    802036e0:	c38d                	beqz	a5,80203702 <syscall+0x5c>
        p->trapFrame->a0 = syscalls[syscall_number]();
    802036e2:	00009717          	auipc	a4,0x9
    802036e6:	aa670713          	addi	a4,a4,-1370 # 8020c188 <syscalls>
    802036ea:	fd043783          	ld	a5,-48(s0)
    802036ee:	078e                	slli	a5,a5,0x3
    802036f0:	97ba                	add	a5,a5,a4
    802036f2:	6398                	ld	a4,0(a5)
    802036f4:	fd843783          	ld	a5,-40(s0)
    802036f8:	7784                	ld	s1,40(a5)
    802036fa:	9702                	jalr	a4
    802036fc:	87aa                	mv	a5,a0
    802036fe:	f8bc                	sd	a5,112(s1)
    80203700:	a811                	j	80203714 <syscall+0x6e>
    } else {
        panic("syscall:unknown syscall");
    80203702:	00008517          	auipc	a0,0x8
    80203706:	c1e50513          	addi	a0,a0,-994 # 8020b320 <etext+0x320>
    8020370a:	fffff097          	auipc	ra,0xfffff
    8020370e:	3fa080e7          	jalr	1018(ra) # 80202b04 <panic>
    }
}
    80203712:	0001                	nop
    80203714:	0001                	nop
    80203716:	70a2                	ld	ra,40(sp)
    80203718:	7402                	ld	s0,32(sp)
    8020371a:	64e2                	ld	s1,24(sp)
    8020371c:	6145                	addi	sp,sp,48
    8020371e:	8082                	ret

0000000080203720 <w_stvec>:
w_stvec(register_t x) {
    80203720:	1101                	addi	sp,sp,-32
    80203722:	ec22                	sd	s0,24(sp)
    80203724:	1000                	addi	s0,sp,32
    80203726:	fea43423          	sd	a0,-24(s0)
    asm volatile("csrw stvec, %0"
    8020372a:	fe843783          	ld	a5,-24(s0)
    8020372e:	10579073          	csrw	stvec,a5
}
    80203732:	0001                	nop
    80203734:	6462                	ld	s0,24(sp)
    80203736:	6105                	addi	sp,sp,32
    80203738:	8082                	ret

000000008020373a <w_sstatus>:
w_sstatus(register_t x) {
    8020373a:	1101                	addi	sp,sp,-32
    8020373c:	ec22                	sd	s0,24(sp)
    8020373e:	1000                	addi	s0,sp,32
    80203740:	fea43423          	sd	a0,-24(s0)
    asm volatile("csrw sstatus, %0"
    80203744:	fe843783          	ld	a5,-24(s0)
    80203748:	10079073          	csrw	sstatus,a5
}
    8020374c:	0001                	nop
    8020374e:	6462                	ld	s0,24(sp)
    80203750:	6105                	addi	sp,sp,32
    80203752:	8082                	ret

0000000080203754 <w_sepc>:
w_sepc(register_t x) {
    80203754:	1101                	addi	sp,sp,-32
    80203756:	ec22                	sd	s0,24(sp)
    80203758:	1000                	addi	s0,sp,32
    8020375a:	fea43423          	sd	a0,-24(s0)
    asm volatile("csrw sepc, %0"
    8020375e:	fe843783          	ld	a5,-24(s0)
    80203762:	14179073          	csrw	sepc,a5
}
    80203766:	0001                	nop
    80203768:	6462                	ld	s0,24(sp)
    8020376a:	6105                	addi	sp,sp,32
    8020376c:	8082                	ret

000000008020376e <w_sie>:
w_sie(register_t x){
    8020376e:	1101                	addi	sp,sp,-32
    80203770:	ec22                	sd	s0,24(sp)
    80203772:	1000                	addi	s0,sp,32
    80203774:	fea43423          	sd	a0,-24(s0)
    asm volatile("csrw sie, %0"
    80203778:	fe843783          	ld	a5,-24(s0)
    8020377c:	10479073          	csrw	sie,a5
}
    80203780:	0001                	nop
    80203782:	6462                	ld	s0,24(sp)
    80203784:	6105                	addi	sp,sp,32
    80203786:	8082                	ret

0000000080203788 <r_satp>:
r_satp(void) {
    80203788:	1101                	addi	sp,sp,-32
    8020378a:	ec22                	sd	s0,24(sp)
    8020378c:	1000                	addi	s0,sp,32
    asm volatile("csrr %0, satp"
    8020378e:	180027f3          	csrr	a5,satp
    80203792:	fef43423          	sd	a5,-24(s0)
    return x;
    80203796:	fe843783          	ld	a5,-24(s0)
}
    8020379a:	853e                	mv	a0,a5
    8020379c:	6462                	ld	s0,24(sp)
    8020379e:	6105                	addi	sp,sp,32
    802037a0:	8082                	ret

00000000802037a2 <r_sstatus>:
r_sstatus(void) {
    802037a2:	1101                	addi	sp,sp,-32
    802037a4:	ec22                	sd	s0,24(sp)
    802037a6:	1000                	addi	s0,sp,32
    asm volatile("csrr %0, sstatus"
    802037a8:	100027f3          	csrr	a5,sstatus
    802037ac:	fef43423          	sd	a5,-24(s0)
    return x;
    802037b0:	fe843783          	ld	a5,-24(s0)
}
    802037b4:	853e                	mv	a0,a5
    802037b6:	6462                	ld	s0,24(sp)
    802037b8:	6105                	addi	sp,sp,32
    802037ba:	8082                	ret

00000000802037bc <r_sie>:
r_sie(void){
    802037bc:	1101                	addi	sp,sp,-32
    802037be:	ec22                	sd	s0,24(sp)
    802037c0:	1000                	addi	s0,sp,32
    asm volatile("csrr %0, sie"
    802037c2:	104027f3          	csrr	a5,sie
    802037c6:	fef43423          	sd	a5,-24(s0)
    return x;
    802037ca:	fe843783          	ld	a5,-24(s0)
}
    802037ce:	853e                	mv	a0,a5
    802037d0:	6462                	ld	s0,24(sp)
    802037d2:	6105                	addi	sp,sp,32
    802037d4:	8082                	ret

00000000802037d6 <r_scause>:
{
    802037d6:	1101                	addi	sp,sp,-32
    802037d8:	ec22                	sd	s0,24(sp)
    802037da:	1000                	addi	s0,sp,32
    asm volatile("csrr %0, scause"
    802037dc:	142027f3          	csrr	a5,scause
    802037e0:	fef43423          	sd	a5,-24(s0)
    return x;
    802037e4:	fe843783          	ld	a5,-24(s0)
}
    802037e8:	853e                	mv	a0,a5
    802037ea:	6462                	ld	s0,24(sp)
    802037ec:	6105                	addi	sp,sp,32
    802037ee:	8082                	ret

00000000802037f0 <r_sepc>:
r_sepc(void){
    802037f0:	1101                	addi	sp,sp,-32
    802037f2:	ec22                	sd	s0,24(sp)
    802037f4:	1000                	addi	s0,sp,32
    asm volatile("csrr %0, sepc"
    802037f6:	141027f3          	csrr	a5,sepc
    802037fa:	fef43423          	sd	a5,-24(s0)
    return x;
    802037fe:	fe843783          	ld	a5,-24(s0)
}
    80203802:	853e                	mv	a0,a5
    80203804:	6462                	ld	s0,24(sp)
    80203806:	6105                	addi	sp,sp,32
    80203808:	8082                	ret

000000008020380a <r_time>:
{
    8020380a:	1101                	addi	sp,sp,-32
    8020380c:	ec22                	sd	s0,24(sp)
    8020380e:	1000                	addi	s0,sp,32
    asm volatile("rdtime %0"
    80203810:	c01027f3          	rdtime	a5
    80203814:	fef43423          	sd	a5,-24(s0)
    return x;
    80203818:	fe843783          	ld	a5,-24(s0)
}
    8020381c:	853e                	mv	a0,a5
    8020381e:	6462                	ld	s0,24(sp)
    80203820:	6105                	addi	sp,sp,32
    80203822:	8082                	ret

0000000080203824 <sbi_getchar>:
static inline int sbi_getchar(void)
{
    80203824:	1141                	addi	sp,sp,-16
    80203826:	e422                	sd	s0,8(sp)
    80203828:	0800                	addi	s0,sp,16
    return SBI_CALL_0(SBI_GETCHAR);
    8020382a:	4501                	li	a0,0
    8020382c:	4581                	li	a1,0
    8020382e:	4601                	li	a2,0
    80203830:	4681                	li	a3,0
    80203832:	4889                	li	a7,2
    80203834:	00000073          	ecall
    80203838:	87aa                	mv	a5,a0
    8020383a:	2781                	sext.w	a5,a5
}
    8020383c:	853e                	mv	a0,a5
    8020383e:	6422                	ld	s0,8(sp)
    80203840:	0141                	addi	sp,sp,16
    80203842:	8082                	ret

0000000080203844 <trapinithart>:
// {
//     printf("kernel trap happen\n");
//     kernelvec();
// }
void
trapinithart(void) {
    80203844:	1141                	addi	sp,sp,-16
    80203846:	e406                	sd	ra,8(sp)
    80203848:	e022                	sd	s0,0(sp)
    8020384a:	0800                	addi	s0,sp,16
    w_stvec((register_t)kernelvec);
    8020384c:	ffffd797          	auipc	a5,0xffffd
    80203850:	84478793          	addi	a5,a5,-1980 # 80200090 <kernelvec>
    80203854:	853e                	mv	a0,a5
    80203856:	00000097          	auipc	ra,0x0
    8020385a:	eca080e7          	jalr	-310(ra) # 80203720 <w_stvec>
    w_sstatus(r_sstatus() | SSTATUS_SIE);
    8020385e:	00000097          	auipc	ra,0x0
    80203862:	f44080e7          	jalr	-188(ra) # 802037a2 <r_sstatus>
    80203866:	87aa                	mv	a5,a0
    80203868:	0027e793          	ori	a5,a5,2
    8020386c:	853e                	mv	a0,a5
    8020386e:	00000097          	auipc	ra,0x0
    80203872:	ecc080e7          	jalr	-308(ra) # 8020373a <w_sstatus>
    w_sie(r_sie() | SIE_SEIE | SIE_SSIE | SIE_STIE);
    80203876:	00000097          	auipc	ra,0x0
    8020387a:	f46080e7          	jalr	-186(ra) # 802037bc <r_sie>
    8020387e:	87aa                	mv	a5,a0
    80203880:	2227e793          	ori	a5,a5,546
    80203884:	853e                	mv	a0,a5
    80203886:	00000097          	auipc	ra,0x0
    8020388a:	ee8080e7          	jalr	-280(ra) # 8020376e <w_sie>
#ifndef DEBUG
    setNextTime();
#endif
    //  sbi_set_extern_interrupt((address_t)hardwareInterrupt);
#ifdef DEBUG
    printf("trapinithart\n");
    8020388e:	00008517          	auipc	a0,0x8
    80203892:	aaa50513          	addi	a0,a0,-1366 # 8020b338 <etext+0x338>
    80203896:	fffff097          	auipc	ra,0xfffff
    8020389a:	05c080e7          	jalr	92(ra) # 802028f2 <printf>
#endif
}
    8020389e:	0001                	nop
    802038a0:	60a2                	ld	ra,8(sp)
    802038a2:	6402                	ld	s0,0(sp)
    802038a4:	0141                	addi	sp,sp,16
    802038a6:	8082                	ret

00000000802038a8 <usertrap>:
void
usertrap(void) {
    802038a8:	7179                	addi	sp,sp,-48
    802038aa:	f406                	sd	ra,40(sp)
    802038ac:	f022                	sd	s0,32(sp)
    802038ae:	ec26                	sd	s1,24(sp)
    802038b0:	1800                	addi	s0,sp,48
    __DEBUG_INFO(usertrap());
    802038b2:	00008517          	auipc	a0,0x8
    802038b6:	a9650513          	addi	a0,a0,-1386 # 8020b348 <etext+0x348>
    802038ba:	fffff097          	auipc	ra,0xfffff
    802038be:	038080e7          	jalr	56(ra) # 802028f2 <printf>
    register_t scause = r_scause();
    802038c2:	00000097          	auipc	ra,0x0
    802038c6:	f14080e7          	jalr	-236(ra) # 802037d6 <r_scause>
    802038ca:	fca43c23          	sd	a0,-40(s0)
    w_stvec((register_t)kernelvec);
    802038ce:	ffffc797          	auipc	a5,0xffffc
    802038d2:	7c278793          	addi	a5,a5,1986 # 80200090 <kernelvec>
    802038d6:	853e                	mv	a0,a5
    802038d8:	00000097          	auipc	ra,0x0
    802038dc:	e48080e7          	jalr	-440(ra) # 80203720 <w_stvec>
    proc_t* p = getCurrentProc();
    802038e0:	ffffe097          	auipc	ra,0xffffe
    802038e4:	2ee080e7          	jalr	750(ra) # 80201bce <getCurrentProc>
    802038e8:	fca43823          	sd	a0,-48(s0)
    p->tms.entry_kernel = r_time();
    802038ec:	00000097          	auipc	ra,0x0
    802038f0:	f1e080e7          	jalr	-226(ra) # 8020380a <r_time>
    802038f4:	872a                	mv	a4,a0
    802038f6:	fd043783          	ld	a5,-48(s0)
    802038fa:	5ce7b023          	sd	a4,1472(a5)
    if (p->tms.entry_kernel > p->tms.leave_kernel) {
    802038fe:	fd043783          	ld	a5,-48(s0)
    80203902:	5c07b703          	ld	a4,1472(a5)
    80203906:	fd043783          	ld	a5,-48(s0)
    8020390a:	5c87b783          	ld	a5,1480(a5)
    8020390e:	04e7f863          	bgeu	a5,a4,8020395e <usertrap+0xb6>
#ifdef QEMU
        p->tms.tms_utime += (p->tms.entry_kernel - p->tms.leave_kernel) / (100000);
    80203912:	fd043783          	ld	a5,-48(s0)
    80203916:	5a07b703          	ld	a4,1440(a5)
    8020391a:	fd043783          	ld	a5,-48(s0)
    8020391e:	5c07b683          	ld	a3,1472(a5)
    80203922:	fd043783          	ld	a5,-48(s0)
    80203926:	5c87b783          	ld	a5,1480(a5)
    8020392a:	8e9d                	sub	a3,a3,a5
    8020392c:	67e1                	lui	a5,0x18
    8020392e:	6a078793          	addi	a5,a5,1696 # 186a0 <_entry-0x801e7960>
    80203932:	02f6d7b3          	divu	a5,a3,a5
    80203936:	973e                	add	a4,a4,a5
    80203938:	fd043783          	ld	a5,-48(s0)
    8020393c:	5ae7b023          	sd	a4,1440(a5)
#else
        p->tms.tms_utime += (p->tms.entry_kernel - p->tms.leave_kernel) / (100000 * 0.65);
#endif
        if (p->parent != NULL) {
    80203940:	fd043783          	ld	a5,-48(s0)
    80203944:	5807b783          	ld	a5,1408(a5)
    80203948:	cb99                	beqz	a5,8020395e <usertrap+0xb6>
            p->parent->tms.tms_cutime = p->tms.tms_utime;
    8020394a:	fd043783          	ld	a5,-48(s0)
    8020394e:	5807b783          	ld	a5,1408(a5)
    80203952:	fd043703          	ld	a4,-48(s0)
    80203956:	5a073703          	ld	a4,1440(a4)
    8020395a:	5ae7b823          	sd	a4,1456(a5)
        }
    }
    p->trapFrame->u_pc = r_sepc();
    8020395e:	fd043783          	ld	a5,-48(s0)
    80203962:	7784                	ld	s1,40(a5)
    80203964:	00000097          	auipc	ra,0x0
    80203968:	e8c080e7          	jalr	-372(ra) # 802037f0 <r_sepc>
    8020396c:	87aa                	mv	a5,a0
    8020396e:	ec9c                	sd	a5,24(s1)
    if (scause == 8) {
    80203970:	fd843703          	ld	a4,-40(s0)
    80203974:	47a1                	li	a5,8
    80203976:	02f71463          	bne	a4,a5,8020399e <usertrap+0xf6>
        p->trapFrame->u_pc += 4;
    8020397a:	fd043783          	ld	a5,-48(s0)
    8020397e:	779c                	ld	a5,40(a5)
    80203980:	6f98                	ld	a4,24(a5)
    80203982:	fd043783          	ld	a5,-48(s0)
    80203986:	779c                	ld	a5,40(a5)
    80203988:	0711                	addi	a4,a4,4
    8020398a:	ef98                	sd	a4,24(a5)
        intr_on();
    8020398c:	00000097          	auipc	ra,0x0
    80203990:	390080e7          	jalr	912(ra) # 80203d1c <intr_on>
        syscall();
    80203994:	00000097          	auipc	ra,0x0
    80203998:	d12080e7          	jalr	-750(ra) # 802036a6 <syscall>
    8020399c:	a091                	j	802039e0 <usertrap+0x138>
    } else {
        // if(hardwareInterrupt() == -1)//TODO
        {
            printf("unknown interrupt\n");
    8020399e:	00008517          	auipc	a0,0x8
    802039a2:	9ba50513          	addi	a0,a0,-1606 # 8020b358 <etext+0x358>
    802039a6:	fffff097          	auipc	ra,0xfffff
    802039aa:	f4c080e7          	jalr	-180(ra) # 802028f2 <printf>
            printf("scause: %x\n", scause);
    802039ae:	fd843583          	ld	a1,-40(s0)
    802039b2:	00008517          	auipc	a0,0x8
    802039b6:	9be50513          	addi	a0,a0,-1602 # 8020b370 <etext+0x370>
    802039ba:	fffff097          	auipc	ra,0xfffff
    802039be:	f38080e7          	jalr	-200(ra) # 802028f2 <printf>
            printf("sepc: %x\n", r_sepc());
    802039c2:	00000097          	auipc	ra,0x0
    802039c6:	e2e080e7          	jalr	-466(ra) # 802037f0 <r_sepc>
    802039ca:	87aa                	mv	a5,a0
    802039cc:	85be                	mv	a1,a5
    802039ce:	00008517          	auipc	a0,0x8
    802039d2:	9b250513          	addi	a0,a0,-1614 # 8020b380 <etext+0x380>
    802039d6:	fffff097          	auipc	ra,0xfffff
    802039da:	f1c080e7          	jalr	-228(ra) # 802028f2 <printf>
            while (1)
    802039de:	a001                	j	802039de <usertrap+0x136>
                ;
        }
    }
    usertrapret();
    802039e0:	00000097          	auipc	ra,0x0
    802039e4:	014080e7          	jalr	20(ra) # 802039f4 <usertrapret>
}
    802039e8:	0001                	nop
    802039ea:	70a2                	ld	ra,40(sp)
    802039ec:	7402                	ld	s0,32(sp)
    802039ee:	64e2                	ld	s1,24(sp)
    802039f0:	6145                	addi	sp,sp,48
    802039f2:	8082                	ret

00000000802039f4 <usertrapret>:

void
usertrapret(void) {
    802039f4:	715d                	addi	sp,sp,-80
    802039f6:	e486                	sd	ra,72(sp)
    802039f8:	e0a2                	sd	s0,64(sp)
    802039fa:	fc26                	sd	s1,56(sp)
    802039fc:	0880                	addi	s0,sp,80
    proc_t* p = getCurrentProc();
    802039fe:	ffffe097          	auipc	ra,0xffffe
    80203a02:	1d0080e7          	jalr	464(ra) # 80201bce <getCurrentProc>
    80203a06:	fca43c23          	sd	a0,-40(s0)
    intr_off();
    80203a0a:	00000097          	auipc	ra,0x0
    80203a0e:	2ea080e7          	jalr	746(ra) # 80203cf4 <intr_off>
    w_stvec(TRAMPOLINE + ((register_t)uservec - (register_t)trampoline));
    80203a12:	00006717          	auipc	a4,0x6
    80203a16:	5ee70713          	addi	a4,a4,1518 # 8020a000 <_trampoline>
    80203a1a:	040007b7          	lui	a5,0x4000
    80203a1e:	17fd                	addi	a5,a5,-1 # 3ffffff <_entry-0x7c200001>
    80203a20:	07b2                	slli	a5,a5,0xc
    80203a22:	973e                	add	a4,a4,a5
    80203a24:	00006797          	auipc	a5,0x6
    80203a28:	5dc78793          	addi	a5,a5,1500 # 8020a000 <_trampoline>
    80203a2c:	40f707b3          	sub	a5,a4,a5
    80203a30:	853e                	mv	a0,a5
    80203a32:	00000097          	auipc	ra,0x0
    80203a36:	cee080e7          	jalr	-786(ra) # 80203720 <w_stvec>
    p->trapFrame->kernel_satp = r_satp();
    80203a3a:	fd843783          	ld	a5,-40(s0)
    80203a3e:	7784                	ld	s1,40(a5)
    80203a40:	00000097          	auipc	ra,0x0
    80203a44:	d48080e7          	jalr	-696(ra) # 80203788 <r_satp>
    80203a48:	87aa                	mv	a5,a0
    80203a4a:	e09c                	sd	a5,0(s1)
    p->trapFrame->kernel_sp = (address_t)p->kstack + PAGE_SIZE;
    80203a4c:	fd843783          	ld	a5,-40(s0)
    80203a50:	73dc                	ld	a5,160(a5)
    80203a52:	86be                	mv	a3,a5
    80203a54:	fd843783          	ld	a5,-40(s0)
    80203a58:	779c                	ld	a5,40(a5)
    80203a5a:	6705                	lui	a4,0x1
    80203a5c:	9736                	add	a4,a4,a3
    80203a5e:	e798                	sd	a4,8(a5)
    p->trapFrame->user_trap_address = (address_t)usertrap;
    80203a60:	fd843783          	ld	a5,-40(s0)
    80203a64:	779c                	ld	a5,40(a5)
    80203a66:	00000717          	auipc	a4,0x0
    80203a6a:	e4270713          	addi	a4,a4,-446 # 802038a8 <usertrap>
    80203a6e:	eb98                	sd	a4,16(a5)

    uint64_t sstatus = r_sstatus();
    80203a70:	00000097          	auipc	ra,0x0
    80203a74:	d32080e7          	jalr	-718(ra) # 802037a2 <r_sstatus>
    80203a78:	fca43823          	sd	a0,-48(s0)
    sstatus = sstatus & (~SSTATUS_SSP);
    80203a7c:	fd043783          	ld	a5,-48(s0)
    80203a80:	eff7f793          	andi	a5,a5,-257
    80203a84:	fcf43823          	sd	a5,-48(s0)
    w_sstatus(sstatus);
    80203a88:	fd043503          	ld	a0,-48(s0)
    80203a8c:	00000097          	auipc	ra,0x0
    80203a90:	cae080e7          	jalr	-850(ra) # 8020373a <w_sstatus>
    intr_on();
    80203a94:	00000097          	auipc	ra,0x0
    80203a98:	288080e7          	jalr	648(ra) # 80203d1c <intr_on>
    w_sepc(p->trapFrame->u_pc);
    80203a9c:	fd843783          	ld	a5,-40(s0)
    80203aa0:	779c                	ld	a5,40(a5)
    80203aa2:	6f9c                	ld	a5,24(a5)
    80203aa4:	853e                	mv	a0,a5
    80203aa6:	00000097          	auipc	ra,0x0
    80203aaa:	cae080e7          	jalr	-850(ra) # 80203754 <w_sepc>
    address_t satp = PAGE_TABLE_SHIFT(p->upageTable);
    80203aae:	fd843783          	ld	a5,-40(s0)
    80203ab2:	6f9c                	ld	a5,24(a5)
    80203ab4:	00c7d713          	srli	a4,a5,0xc
    80203ab8:	57fd                	li	a5,-1
    80203aba:	17fe                	slli	a5,a5,0x3f
    80203abc:	8fd9                	or	a5,a5,a4
    80203abe:	fcf43423          	sd	a5,-56(s0)
    address_t fn = TRAMPOLINE + ((register_t)userret - (register_t)trampoline);
    80203ac2:	00006717          	auipc	a4,0x6
    80203ac6:	5ce70713          	addi	a4,a4,1486 # 8020a090 <userret>
    80203aca:	040007b7          	lui	a5,0x4000
    80203ace:	17fd                	addi	a5,a5,-1 # 3ffffff <_entry-0x7c200001>
    80203ad0:	07b2                	slli	a5,a5,0xc
    80203ad2:	973e                	add	a4,a4,a5
    80203ad4:	00006797          	auipc	a5,0x6
    80203ad8:	52c78793          	addi	a5,a5,1324 # 8020a000 <_trampoline>
    80203adc:	40f707b3          	sub	a5,a4,a5
    80203ae0:	fcf43023          	sd	a5,-64(s0)
    // address_t fn = TRAMPOLINE;
    // address_t fn = TRAMRET;
    p->tms.leave_kernel = r_time();
    80203ae4:	00000097          	auipc	ra,0x0
    80203ae8:	d26080e7          	jalr	-730(ra) # 8020380a <r_time>
    80203aec:	872a                	mv	a4,a0
    80203aee:	fd843783          	ld	a5,-40(s0)
    80203af2:	5ce7b423          	sd	a4,1480(a5)
    if (p->tms.leave_kernel > p->tms.entry_kernel) {
    80203af6:	fd843783          	ld	a5,-40(s0)
    80203afa:	5c87b703          	ld	a4,1480(a5)
    80203afe:	fd843783          	ld	a5,-40(s0)
    80203b02:	5c07b783          	ld	a5,1472(a5)
    80203b06:	04e7f663          	bgeu	a5,a4,80203b52 <usertrapret+0x15e>
#ifdef QEMU
        p->tms.tms_stime += (p->tms.leave_kernel - p->tms.entry_kernel) / (100000);
    80203b0a:	fd843783          	ld	a5,-40(s0)
    80203b0e:	5a87b703          	ld	a4,1448(a5)
    80203b12:	fd843783          	ld	a5,-40(s0)
    80203b16:	5c87b683          	ld	a3,1480(a5)
    80203b1a:	fd843783          	ld	a5,-40(s0)
    80203b1e:	5c07b783          	ld	a5,1472(a5)
    80203b22:	8e9d                	sub	a3,a3,a5
    80203b24:	67e1                	lui	a5,0x18
    80203b26:	6a078793          	addi	a5,a5,1696 # 186a0 <_entry-0x801e7960>
    80203b2a:	02f6d7b3          	divu	a5,a3,a5
    80203b2e:	973e                	add	a4,a4,a5
    80203b30:	fd843783          	ld	a5,-40(s0)
    80203b34:	5ae7b423          	sd	a4,1448(a5)
#else
        p->tms.tms_stime += (p->tms.leave_kernel - p->tms.entry_kernel) / (100000 * 0.65);
#endif
        if (p->parent != NULL) {
    80203b38:	fd843783          	ld	a5,-40(s0)
    80203b3c:	5807b783          	ld	a5,1408(a5)
    80203b40:	cb89                	beqz	a5,80203b52 <usertrapret+0x15e>
            p->tms.tms_cstime = p->tms.tms_stime;
    80203b42:	fd843783          	ld	a5,-40(s0)
    80203b46:	5a87b703          	ld	a4,1448(a5)
    80203b4a:	fd843783          	ld	a5,-40(s0)
    80203b4e:	5ae7bc23          	sd	a4,1464(a5)
        }
    }
    void* address = (void*)kvm_trans(fn, p->kpageTable);  // TODO
    80203b52:	fd843783          	ld	a5,-40(s0)
    80203b56:	739c                	ld	a5,32(a5)
    80203b58:	85be                	mv	a1,a5
    80203b5a:	fc043503          	ld	a0,-64(s0)
    80203b5e:	ffffd097          	auipc	ra,0xffffd
    80203b62:	036080e7          	jalr	54(ra) # 80200b94 <kvm_trans>
    80203b66:	87aa                	mv	a5,a0
    80203b68:	faf43c23          	sd	a5,-72(s0)
    ((void (*)(register_t, register_t))fn)(TRAP_FRAME, satp);
    80203b6c:	fc043703          	ld	a4,-64(s0)
    80203b70:	fc843583          	ld	a1,-56(s0)
    80203b74:	020007b7          	lui	a5,0x2000
    80203b78:	17fd                	addi	a5,a5,-1 # 1ffffff <_entry-0x7e200001>
    80203b7a:	00d79513          	slli	a0,a5,0xd
    80203b7e:	9702                	jalr	a4
}
    80203b80:	0001                	nop
    80203b82:	60a6                	ld	ra,72(sp)
    80203b84:	6406                	ld	s0,64(sp)
    80203b86:	74e2                	ld	s1,56(sp)
    80203b88:	6161                	addi	sp,sp,80
    80203b8a:	8082                	ret

0000000080203b8c <hardwareInterrupt>:

uint32_t
hardwareInterrupt(void) {
    80203b8c:	7139                	addi	sp,sp,-64
    80203b8e:	fc06                	sd	ra,56(sp)
    80203b90:	f822                	sd	s0,48(sp)
    80203b92:	0080                	addi	s0,sp,64
    // printf("extern trap");

    register_t scause = r_scause();
    80203b94:	00000097          	auipc	ra,0x0
    80203b98:	c42080e7          	jalr	-958(ra) # 802037d6 <r_scause>
    80203b9c:	fea43023          	sd	a0,-32(s0)
#ifdef QEMU
    if (scause == 0x8000000000000009)
    80203ba0:	fe043703          	ld	a4,-32(s0)
    80203ba4:	57fd                	li	a5,-1
    80203ba6:	17fe                	slli	a5,a5,0x3f
    80203ba8:	07a5                	addi	a5,a5,9
    80203baa:	0af71163          	bne	a4,a5,80203c4c <hardwareInterrupt+0xc0>
#else
    if ((scause == 0X8000000000000001L) && (r_stval() == 9))
#endif
    {
        int ret;
        uint64_t irq = plic_claim();
    80203bae:	00000097          	auipc	ra,0x0
    80203bb2:	3f4080e7          	jalr	1012(ra) # 80203fa2 <plic_claim>
    80203bb6:	87aa                	mv	a5,a0
    80203bb8:	fcf43823          	sd	a5,-48(s0)
        if (irq == UART_IRQ) {
    80203bbc:	fd043703          	ld	a4,-48(s0)
    80203bc0:	47a9                	li	a5,10
    80203bc2:	02f71b63          	bne	a4,a5,80203bf8 <hardwareInterrupt+0x6c>
            int c = sbi_getchar();
    80203bc6:	00000097          	auipc	ra,0x0
    80203bca:	c5e080e7          	jalr	-930(ra) # 80203824 <sbi_getchar>
    80203bce:	87aa                	mv	a5,a0
    80203bd0:	fcf42623          	sw	a5,-52(s0)
            if (c != -1)
    80203bd4:	fcc42783          	lw	a5,-52(s0)
    80203bd8:	0007871b          	sext.w	a4,a5
    80203bdc:	57fd                	li	a5,-1
    80203bde:	00f70963          	beq	a4,a5,80203bf0 <hardwareInterrupt+0x64>
                console_intr(c);
    80203be2:	fcc42783          	lw	a5,-52(s0)
    80203be6:	853e                	mv	a0,a5
    80203be8:	ffffd097          	auipc	ra,0xffffd
    80203bec:	8c8080e7          	jalr	-1848(ra) # 802004b0 <console_intr>
            ret = 1;
    80203bf0:	4785                	li	a5,1
    80203bf2:	fef42623          	sw	a5,-20(s0)
    80203bf6:	a82d                	j	80203c30 <hardwareInterrupt+0xa4>
        } else if (irq == DISK_IRQ) {
    80203bf8:	fd043703          	ld	a4,-48(s0)
    80203bfc:	4785                	li	a5,1
    80203bfe:	00f71a63          	bne	a4,a5,80203c12 <hardwareInterrupt+0x86>
            disk_intr();
    80203c02:	00004097          	auipc	ra,0x4
    80203c06:	d72080e7          	jalr	-654(ra) # 80207974 <disk_intr>
            ret = 2;
    80203c0a:	4789                	li	a5,2
    80203c0c:	fef42623          	sw	a5,-20(s0)
    80203c10:	a005                	j	80203c30 <hardwareInterrupt+0xa4>
        } else if (irq) {
    80203c12:	fd043783          	ld	a5,-48(s0)
    80203c16:	cf89                	beqz	a5,80203c30 <hardwareInterrupt+0xa4>
            printf("unexpected interrupt irq = %d\n", irq);
    80203c18:	fd043583          	ld	a1,-48(s0)
    80203c1c:	00007517          	auipc	a0,0x7
    80203c20:	77450513          	addi	a0,a0,1908 # 8020b390 <etext+0x390>
    80203c24:	fffff097          	auipc	ra,0xfffff
    80203c28:	cce080e7          	jalr	-818(ra) # 802028f2 <printf>
            ret = 0;
    80203c2c:	fe042623          	sw	zero,-20(s0)
        }
        if (irq)
    80203c30:	fd043783          	ld	a5,-48(s0)
    80203c34:	cb89                	beqz	a5,80203c46 <hardwareInterrupt+0xba>
            plic_complete(irq);
    80203c36:	fd043783          	ld	a5,-48(s0)
    80203c3a:	2781                	sext.w	a5,a5
    80203c3c:	853e                	mv	a0,a5
    80203c3e:	00000097          	auipc	ra,0x0
    80203c42:	3a6080e7          	jalr	934(ra) # 80203fe4 <plic_complete>
#ifndef QEMU
        w_sip(r_sip() & ~2);
        sbi_set_mie();
#endif
        return ret;
    80203c46:	fec42783          	lw	a5,-20(s0)
    80203c4a:	a899                	j	80203ca0 <hardwareInterrupt+0x114>
    } else if (scause == 0x8000000000000005) {
    80203c4c:	fe043703          	ld	a4,-32(s0)
    80203c50:	57fd                	li	a5,-1
    80203c52:	17fe                	slli	a5,a5,0x3f
    80203c54:	0795                	addi	a5,a5,5
    80203c56:	02f71c63          	bne	a4,a5,80203c8e <hardwareInterrupt+0x102>
        // #ifdef DEBUG
        //         printf("receive time trap\n");
        // #endif
        setNextTime();
    80203c5a:	00000097          	auipc	ra,0x0
    80203c5e:	226080e7          	jalr	550(ra) # 80203e80 <setNextTime>
        proc_t* proc = getCurrentProc();
    80203c62:	ffffe097          	auipc	ra,0xffffe
    80203c66:	f6c080e7          	jalr	-148(ra) # 80201bce <getCurrentProc>
    80203c6a:	fca43c23          	sd	a0,-40(s0)
        if ((proc != NULL) && (proc->state == RUNNING)) {
    80203c6e:	fd843783          	ld	a5,-40(s0)
    80203c72:	cf81                	beqz	a5,80203c8a <hardwareInterrupt+0xfe>
    80203c74:	fd843783          	ld	a5,-40(s0)
    80203c78:	439c                	lw	a5,0(a5)
    80203c7a:	873e                	mv	a4,a5
    80203c7c:	478d                	li	a5,3
    80203c7e:	00f71663          	bne	a4,a5,80203c8a <hardwareInterrupt+0xfe>
            yield();
    80203c82:	ffffe097          	auipc	ra,0xffffe
    80203c86:	5d6080e7          	jalr	1494(ra) # 80202258 <yield>
        }
        return 3;
    80203c8a:	478d                	li	a5,3
    80203c8c:	a811                	j	80203ca0 <hardwareInterrupt+0x114>
    } else {
        printf("unexpected interrupt\n");
    80203c8e:	00007517          	auipc	a0,0x7
    80203c92:	72250513          	addi	a0,a0,1826 # 8020b3b0 <etext+0x3b0>
    80203c96:	fffff097          	auipc	ra,0xfffff
    80203c9a:	c5c080e7          	jalr	-932(ra) # 802028f2 <printf>
        return 0;
    80203c9e:	4781                	li	a5,0
    }
}
    80203ca0:	853e                	mv	a0,a5
    80203ca2:	70e2                	ld	ra,56(sp)
    80203ca4:	7442                	ld	s0,48(sp)
    80203ca6:	6121                	addi	sp,sp,64
    80203ca8:	8082                	ret

0000000080203caa <kernel_trap>:

void
kernel_trap() {
    80203caa:	1101                	addi	sp,sp,-32
    80203cac:	ec06                	sd	ra,24(sp)
    80203cae:	e822                	sd	s0,16(sp)
    80203cb0:	1000                	addi	s0,sp,32
    //   printf("kernel_trap");
    address_t sepc = r_sepc();
    80203cb2:	00000097          	auipc	ra,0x0
    80203cb6:	b3e080e7          	jalr	-1218(ra) # 802037f0 <r_sepc>
    80203cba:	fea43423          	sd	a0,-24(s0)
    address_t sstatus = r_sstatus();
    80203cbe:	00000097          	auipc	ra,0x0
    80203cc2:	ae4080e7          	jalr	-1308(ra) # 802037a2 <r_sstatus>
    80203cc6:	fea43023          	sd	a0,-32(s0)

    hardwareInterrupt();
    80203cca:	00000097          	auipc	ra,0x0
    80203cce:	ec2080e7          	jalr	-318(ra) # 80203b8c <hardwareInterrupt>

    w_sepc(sepc);
    80203cd2:	fe843503          	ld	a0,-24(s0)
    80203cd6:	00000097          	auipc	ra,0x0
    80203cda:	a7e080e7          	jalr	-1410(ra) # 80203754 <w_sepc>
    w_sstatus(sstatus);
    80203cde:	fe043503          	ld	a0,-32(s0)
    80203ce2:	00000097          	auipc	ra,0x0
    80203ce6:	a58080e7          	jalr	-1448(ra) # 8020373a <w_sstatus>
}
    80203cea:	0001                	nop
    80203cec:	60e2                	ld	ra,24(sp)
    80203cee:	6442                	ld	s0,16(sp)
    80203cf0:	6105                	addi	sp,sp,32
    80203cf2:	8082                	ret

0000000080203cf4 <intr_off>:
void
intr_off(void) {
    80203cf4:	1141                	addi	sp,sp,-16
    80203cf6:	e406                	sd	ra,8(sp)
    80203cf8:	e022                	sd	s0,0(sp)
    80203cfa:	0800                	addi	s0,sp,16
    w_sstatus(r_sstatus() & (~SSTATUS_SIE));
    80203cfc:	00000097          	auipc	ra,0x0
    80203d00:	aa6080e7          	jalr	-1370(ra) # 802037a2 <r_sstatus>
    80203d04:	87aa                	mv	a5,a0
    80203d06:	9bf5                	andi	a5,a5,-3
    80203d08:	853e                	mv	a0,a5
    80203d0a:	00000097          	auipc	ra,0x0
    80203d0e:	a30080e7          	jalr	-1488(ra) # 8020373a <w_sstatus>
}
    80203d12:	0001                	nop
    80203d14:	60a2                	ld	ra,8(sp)
    80203d16:	6402                	ld	s0,0(sp)
    80203d18:	0141                	addi	sp,sp,16
    80203d1a:	8082                	ret

0000000080203d1c <intr_on>:

void
intr_on(void) {
    80203d1c:	1141                	addi	sp,sp,-16
    80203d1e:	e406                	sd	ra,8(sp)
    80203d20:	e022                	sd	s0,0(sp)
    80203d22:	0800                	addi	s0,sp,16
    w_sstatus(r_sstatus() | SSTATUS_SIE);
    80203d24:	00000097          	auipc	ra,0x0
    80203d28:	a7e080e7          	jalr	-1410(ra) # 802037a2 <r_sstatus>
    80203d2c:	87aa                	mv	a5,a0
    80203d2e:	0027e793          	ori	a5,a5,2
    80203d32:	853e                	mv	a0,a5
    80203d34:	00000097          	auipc	ra,0x0
    80203d38:	a06080e7          	jalr	-1530(ra) # 8020373a <w_sstatus>
}
    80203d3c:	0001                	nop
    80203d3e:	60a2                	ld	ra,8(sp)
    80203d40:	6402                	ld	s0,0(sp)
    80203d42:	0141                	addi	sp,sp,16
    80203d44:	8082                	ret

0000000080203d46 <intr_get>:

uint32_t
intr_get(void) {
    80203d46:	1141                	addi	sp,sp,-16
    80203d48:	e406                	sd	ra,8(sp)
    80203d4a:	e022                	sd	s0,0(sp)
    80203d4c:	0800                	addi	s0,sp,16
    return (r_sstatus() & SSTATUS_SIE) != 0;
    80203d4e:	00000097          	auipc	ra,0x0
    80203d52:	a54080e7          	jalr	-1452(ra) # 802037a2 <r_sstatus>
    80203d56:	87aa                	mv	a5,a0
    80203d58:	8b89                	andi	a5,a5,2
    80203d5a:	00f037b3          	snez	a5,a5
    80203d5e:	0ff7f793          	zext.b	a5,a5
    80203d62:	2781                	sext.w	a5,a5
}
    80203d64:	853e                	mv	a0,a5
    80203d66:	60a2                	ld	ra,8(sp)
    80203d68:	6402                	ld	s0,0(sp)
    80203d6a:	0141                	addi	sp,sp,16
    80203d6c:	8082                	ret

0000000080203d6e <intr_pop>:
void
intr_pop(void) {
    80203d6e:	1101                	addi	sp,sp,-32
    80203d70:	ec06                	sd	ra,24(sp)
    80203d72:	e822                	sd	s0,16(sp)
    80203d74:	1000                	addi	s0,sp,32
    cpu_t* c = getCurrentCPU();
    80203d76:	ffffe097          	auipc	ra,0xffffe
    80203d7a:	4b8080e7          	jalr	1208(ra) # 8020222e <getCurrentCPU>
    80203d7e:	fea43423          	sd	a0,-24(s0)
    if (intr_get()) {
    80203d82:	00000097          	auipc	ra,0x0
    80203d86:	fc4080e7          	jalr	-60(ra) # 80203d46 <intr_get>
    80203d8a:	87aa                	mv	a5,a0
    80203d8c:	2781                	sext.w	a5,a5
    80203d8e:	cb91                	beqz	a5,80203da2 <intr_pop+0x34>
        panic("intr_pop: interruptable");
    80203d90:	00007517          	auipc	a0,0x7
    80203d94:	63850513          	addi	a0,a0,1592 # 8020b3c8 <etext+0x3c8>
    80203d98:	fffff097          	auipc	ra,0xfffff
    80203d9c:	d6c080e7          	jalr	-660(ra) # 80202b04 <panic>
        while (1)
    80203da0:	a001                	j	80203da0 <intr_pop+0x32>
            ;
    }
    if (c->lk_num < 1) {
    80203da2:	fe843783          	ld	a5,-24(s0)
    80203da6:	5fbc                	lw	a5,120(a5)
    80203da8:	eb91                	bnez	a5,80203dbc <intr_pop+0x4e>
        panic("intr_pop: no push before");
    80203daa:	00007517          	auipc	a0,0x7
    80203dae:	63650513          	addi	a0,a0,1590 # 8020b3e0 <etext+0x3e0>
    80203db2:	fffff097          	auipc	ra,0xfffff
    80203db6:	d52080e7          	jalr	-686(ra) # 80202b04 <panic>
        while (1)
    80203dba:	a001                	j	80203dba <intr_pop+0x4c>
            ;
    }
    c->lk_num--;
    80203dbc:	fe843783          	ld	a5,-24(s0)
    80203dc0:	5fbc                	lw	a5,120(a5)
    80203dc2:	37fd                	addiw	a5,a5,-1
    80203dc4:	0007871b          	sext.w	a4,a5
    80203dc8:	fe843783          	ld	a5,-24(s0)
    80203dcc:	dfb8                	sw	a4,120(a5)
    if ((c->lk_num == 0) && (c->before_lk_intr)) {
    80203dce:	fe843783          	ld	a5,-24(s0)
    80203dd2:	5fbc                	lw	a5,120(a5)
    80203dd4:	eb89                	bnez	a5,80203de6 <intr_pop+0x78>
    80203dd6:	fe843783          	ld	a5,-24(s0)
    80203dda:	5ffc                	lw	a5,124(a5)
    80203ddc:	c789                	beqz	a5,80203de6 <intr_pop+0x78>
        intr_on();
    80203dde:	00000097          	auipc	ra,0x0
    80203de2:	f3e080e7          	jalr	-194(ra) # 80203d1c <intr_on>
    }
}
    80203de6:	0001                	nop
    80203de8:	60e2                	ld	ra,24(sp)
    80203dea:	6442                	ld	s0,16(sp)
    80203dec:	6105                	addi	sp,sp,32
    80203dee:	8082                	ret

0000000080203df0 <intr_push>:

void
intr_push(void) {
    80203df0:	1101                	addi	sp,sp,-32
    80203df2:	ec06                	sd	ra,24(sp)
    80203df4:	e822                	sd	s0,16(sp)
    80203df6:	1000                	addi	s0,sp,32
    intr_off();
    80203df8:	00000097          	auipc	ra,0x0
    80203dfc:	efc080e7          	jalr	-260(ra) # 80203cf4 <intr_off>
    cpu_t* c = getCurrentCPU();
    80203e00:	ffffe097          	auipc	ra,0xffffe
    80203e04:	42e080e7          	jalr	1070(ra) # 8020222e <getCurrentCPU>
    80203e08:	fea43423          	sd	a0,-24(s0)
    if (c->lk_num == 0) {
    80203e0c:	fe843783          	ld	a5,-24(s0)
    80203e10:	5fbc                	lw	a5,120(a5)
    80203e12:	eb99                	bnez	a5,80203e28 <intr_push+0x38>
        c->before_lk_intr = intr_get();
    80203e14:	00000097          	auipc	ra,0x0
    80203e18:	f32080e7          	jalr	-206(ra) # 80203d46 <intr_get>
    80203e1c:	87aa                	mv	a5,a0
    80203e1e:	0007871b          	sext.w	a4,a5
    80203e22:	fe843783          	ld	a5,-24(s0)
    80203e26:	dff8                	sw	a4,124(a5)
    }
    c->lk_num++;
    80203e28:	fe843783          	ld	a5,-24(s0)
    80203e2c:	5fbc                	lw	a5,120(a5)
    80203e2e:	2785                	addiw	a5,a5,1
    80203e30:	0007871b          	sext.w	a4,a5
    80203e34:	fe843783          	ld	a5,-24(s0)
    80203e38:	dfb8                	sw	a4,120(a5)
    80203e3a:	0001                	nop
    80203e3c:	60e2                	ld	ra,24(sp)
    80203e3e:	6442                	ld	s0,16(sp)
    80203e40:	6105                	addi	sp,sp,32
    80203e42:	8082                	ret

0000000080203e44 <sbi_set_time>:
static inline void sbi_set_time(register_t time)
{
    80203e44:	1101                	addi	sp,sp,-32
    80203e46:	ec22                	sd	s0,24(sp)
    80203e48:	1000                	addi	s0,sp,32
    80203e4a:	fea43423          	sd	a0,-24(s0)
    SBI_CALL_1(SBI_SET_TIMER, time);
    80203e4e:	fe843503          	ld	a0,-24(s0)
    80203e52:	4581                	li	a1,0
    80203e54:	4601                	li	a2,0
    80203e56:	4681                	li	a3,0
    80203e58:	4881                	li	a7,0
    80203e5a:	00000073          	ecall
}
    80203e5e:	0001                	nop
    80203e60:	6462                	ld	s0,24(sp)
    80203e62:	6105                	addi	sp,sp,32
    80203e64:	8082                	ret

0000000080203e66 <r_time>:
{
    80203e66:	1101                	addi	sp,sp,-32
    80203e68:	ec22                	sd	s0,24(sp)
    80203e6a:	1000                	addi	s0,sp,32
    asm volatile("rdtime %0"
    80203e6c:	c01027f3          	rdtime	a5
    80203e70:	fef43423          	sd	a5,-24(s0)
    return x;
    80203e74:	fe843783          	ld	a5,-24(s0)
}
    80203e78:	853e                	mv	a0,a5
    80203e7a:	6462                	ld	s0,24(sp)
    80203e7c:	6105                	addi	sp,sp,32
    80203e7e:	8082                	ret

0000000080203e80 <setNextTime>:
spinlock_t time_lk;
#ifdef DEBUG
int times = 0;
#endif 
void setNextTime(void)
{
    80203e80:	1141                	addi	sp,sp,-16
    80203e82:	e406                	sd	ra,8(sp)
    80203e84:	e022                	sd	s0,0(sp)
    80203e86:	0800                	addi	s0,sp,16
    // times++;
    // if(times == 2)
    //     while(1);
    // #endif
    //printf("");
    sbi_set_time(r_time() + TICKS);
    80203e88:	00000097          	auipc	ra,0x0
    80203e8c:	fde080e7          	jalr	-34(ra) # 80203e66 <r_time>
    80203e90:	872a                	mv	a4,a0
    80203e92:	001dc7b7          	lui	a5,0x1dc
    80203e96:	13078793          	addi	a5,a5,304 # 1dc130 <_entry-0x80023ed0>
    80203e9a:	97ba                	add	a5,a5,a4
    80203e9c:	853e                	mv	a0,a5
    80203e9e:	00000097          	auipc	ra,0x0
    80203ea2:	fa6080e7          	jalr	-90(ra) # 80203e44 <sbi_set_time>
}
    80203ea6:	0001                	nop
    80203ea8:	60a2                	ld	ra,8(sp)
    80203eaa:	6402                	ld	s0,0(sp)
    80203eac:	0141                	addi	sp,sp,16
    80203eae:	8082                	ret

0000000080203eb0 <timerInit>:

void timerInit(void)
{
    80203eb0:	1141                	addi	sp,sp,-16
    80203eb2:	e406                	sd	ra,8(sp)
    80203eb4:	e022                	sd	s0,0(sp)
    80203eb6:	0800                	addi	s0,sp,16
    spinlock_init(&time_lk, "time");
    80203eb8:	00007597          	auipc	a1,0x7
    80203ebc:	54858593          	addi	a1,a1,1352 # 8020b400 <etext+0x400>
    80203ec0:	00023517          	auipc	a0,0x23
    80203ec4:	71050513          	addi	a0,a0,1808 # 802275d0 <time_lk>
    80203ec8:	00001097          	auipc	ra,0x1
    80203ecc:	a5a080e7          	jalr	-1446(ra) # 80204922 <spinlock_init>
}
    80203ed0:	0001                	nop
    80203ed2:	60a2                	ld	ra,8(sp)
    80203ed4:	6402                	ld	s0,0(sp)
    80203ed6:	0141                	addi	sp,sp,16
    80203ed8:	8082                	ret

0000000080203eda <r_tp>:
{
    80203eda:	1101                	addi	sp,sp,-32
    80203edc:	ec22                	sd	s0,24(sp)
    80203ede:	1000                	addi	s0,sp,32
    asm volatile("mv %0, tp"
    80203ee0:	8792                	mv	a5,tp
    80203ee2:	fef43423          	sd	a5,-24(s0)
    return x;
    80203ee6:	fe843783          	ld	a5,-24(s0)
}
    80203eea:	853e                	mv	a0,a5
    80203eec:	6462                	ld	s0,24(sp)
    80203eee:	6105                	addi	sp,sp,32
    80203ef0:	8082                	ret

0000000080203ef2 <plicinit>:
#define WRITE_W(v, addr) (*(volatile uint16_t*)(addr)) = (v)
#define WRITE_D(v, addr) (*(volatile uint32_t*)(addr)) = (v)
#define WRITE_Q(v, addr) (*(volatile uint64_t*)(addr)) = (v)

void
plicinit(void) {
    80203ef2:	1141                	addi	sp,sp,-16
    80203ef4:	e406                	sd	ra,8(sp)
    80203ef6:	e022                	sd	s0,0(sp)
    80203ef8:	0800                	addi	s0,sp,16
    WRITE_D(1, PLIC_V + DISK_IRQ * sizeof(uint32_t));
    80203efa:	00fc37b7          	lui	a5,0xfc3
    80203efe:	07ba                	slli	a5,a5,0xe
    80203f00:	0791                	addi	a5,a5,4 # fc3004 <_entry-0x7f23cffc>
    80203f02:	4705                	li	a4,1
    80203f04:	c398                	sw	a4,0(a5)
    WRITE_D(1, PLIC_V + UART_IRQ * sizeof(uint32_t));
    80203f06:	00fc37b7          	lui	a5,0xfc3
    80203f0a:	07ba                	slli	a5,a5,0xe
    80203f0c:	02878793          	addi	a5,a5,40 # fc3028 <_entry-0x7f23cfd8>
    80203f10:	4705                	li	a4,1
    80203f12:	c398                	sw	a4,0(a5)
    __DEBUG_INFO(plicinit() over);
    80203f14:	00007517          	auipc	a0,0x7
    80203f18:	4f450513          	addi	a0,a0,1268 # 8020b408 <etext+0x408>
    80203f1c:	fffff097          	auipc	ra,0xfffff
    80203f20:	9d6080e7          	jalr	-1578(ra) # 802028f2 <printf>
}
    80203f24:	0001                	nop
    80203f26:	60a2                	ld	ra,8(sp)
    80203f28:	6402                	ld	s0,0(sp)
    80203f2a:	0141                	addi	sp,sp,16
    80203f2c:	8082                	ret

0000000080203f2e <plicinithart>:

void
plicinithart(void) {
    80203f2e:	1101                	addi	sp,sp,-32
    80203f30:	ec06                	sd	ra,24(sp)
    80203f32:	e822                	sd	s0,16(sp)
    80203f34:	1000                	addi	s0,sp,32
    uint32_t hart = r_tp();
    80203f36:	00000097          	auipc	ra,0x0
    80203f3a:	fa4080e7          	jalr	-92(ra) # 80203eda <r_tp>
    80203f3e:	87aa                	mv	a5,a0
    80203f40:	fef42623          	sw	a5,-20(s0)
#ifdef QEMU
    // set uart's enable bit for this hart's S-mode.
    *(uint32_t*)PLIC_SENABLE(hart) = (1 << UART_IRQ) | (1 << DISK_IRQ);
    80203f44:	fec42783          	lw	a5,-20(s0)
    80203f48:	0087979b          	slliw	a5,a5,0x8
    80203f4c:	2781                	sext.w	a5,a5
    80203f4e:	02079713          	slli	a4,a5,0x20
    80203f52:	9301                	srli	a4,a4,0x20
    80203f54:	7e1807b7          	lui	a5,0x7e180
    80203f58:	04178793          	addi	a5,a5,65 # 7e180041 <_entry-0x207ffbf>
    80203f5c:	079e                	slli	a5,a5,0x7
    80203f5e:	97ba                	add	a5,a5,a4
    80203f60:	873e                	mv	a4,a5
    80203f62:	40200793          	li	a5,1026
    80203f66:	c31c                	sw	a5,0(a4)
    // set this hart's S-mode priority threshold to 0
    *(uint32_t*)PLIC_SPRIORITY(hart) = 0;
    80203f68:	fec42783          	lw	a5,-20(s0)
    80203f6c:	00d7979b          	slliw	a5,a5,0xd
    80203f70:	2781                	sext.w	a5,a5
    80203f72:	02079713          	slli	a4,a5,0x20
    80203f76:	9301                	srli	a4,a4,0x20
    80203f78:	03f0c7b7          	lui	a5,0x3f0c
    80203f7c:	20178793          	addi	a5,a5,513 # 3f0c201 <_entry-0x7c2f3dff>
    80203f80:	07b2                	slli	a5,a5,0xc
    80203f82:	97ba                	add	a5,a5,a4
    80203f84:	0007a023          	sw	zero,0(a5)
    uint32_t* hart_m_enable = (uint32_t*)PLIC_MENABLE(hart);
    *(hart_m_enable) = readd(hart_m_enable) | (1 << DISK_IRQ);
    uint32_t* hart0_m_int_enable_hi = hart_m_enable + 1;
    *(hart0_m_int_enable_hi) = readd(hart0_m_int_enable_hi) | (1 << (UART_IRQ % 32));
#endif
    __DEBUG_INFO(plicinithart() over);
    80203f88:	00007517          	auipc	a0,0x7
    80203f8c:	49850513          	addi	a0,a0,1176 # 8020b420 <etext+0x420>
    80203f90:	fffff097          	auipc	ra,0xfffff
    80203f94:	962080e7          	jalr	-1694(ra) # 802028f2 <printf>
}
    80203f98:	0001                	nop
    80203f9a:	60e2                	ld	ra,24(sp)
    80203f9c:	6442                	ld	s0,16(sp)
    80203f9e:	6105                	addi	sp,sp,32
    80203fa0:	8082                	ret

0000000080203fa2 <plic_claim>:

int
plic_claim(void) {
    80203fa2:	1101                	addi	sp,sp,-32
    80203fa4:	ec06                	sd	ra,24(sp)
    80203fa6:	e822                	sd	s0,16(sp)
    80203fa8:	1000                	addi	s0,sp,32
    int hart = r_tp();
    80203faa:	00000097          	auipc	ra,0x0
    80203fae:	f30080e7          	jalr	-208(ra) # 80203eda <r_tp>
    80203fb2:	87aa                	mv	a5,a0
    80203fb4:	fef42623          	sw	a5,-20(s0)
    int irq;
#ifdef QEMU
    irq = *(uint32_t*)PLIC_SCLAIM(hart);
    80203fb8:	fec42783          	lw	a5,-20(s0)
    80203fbc:	00d7979b          	slliw	a5,a5,0xd
    80203fc0:	2781                	sext.w	a5,a5
    80203fc2:	873e                	mv	a4,a5
    80203fc4:	00007797          	auipc	a5,0x7
    80203fc8:	47478793          	addi	a5,a5,1140 # 8020b438 <etext+0x438>
    80203fcc:	639c                	ld	a5,0(a5)
    80203fce:	97ba                	add	a5,a5,a4
    80203fd0:	439c                	lw	a5,0(a5)
    80203fd2:	fef42423          	sw	a5,-24(s0)
#endif

#ifdef DEBUG
    // printf("plic_claim, irq = %d\n", irq);
#endif
    return irq;
    80203fd6:	fe842783          	lw	a5,-24(s0)
}
    80203fda:	853e                	mv	a0,a5
    80203fdc:	60e2                	ld	ra,24(sp)
    80203fde:	6442                	ld	s0,16(sp)
    80203fe0:	6105                	addi	sp,sp,32
    80203fe2:	8082                	ret

0000000080203fe4 <plic_complete>:

void
plic_complete(int irq) {
    80203fe4:	7179                	addi	sp,sp,-48
    80203fe6:	f406                	sd	ra,40(sp)
    80203fe8:	f022                	sd	s0,32(sp)
    80203fea:	1800                	addi	s0,sp,48
    80203fec:	87aa                	mv	a5,a0
    80203fee:	fcf42e23          	sw	a5,-36(s0)
    int hart = r_tp();
    80203ff2:	00000097          	auipc	ra,0x0
    80203ff6:	ee8080e7          	jalr	-280(ra) # 80203eda <r_tp>
    80203ffa:	87aa                	mv	a5,a0
    80203ffc:	fef42623          	sw	a5,-20(s0)
#ifdef QEMU
    *(uint32_t*)PLIC_MCLAIM(hart) = irq;
    80204000:	fec42783          	lw	a5,-20(s0)
    80204004:	00d7979b          	slliw	a5,a5,0xd
    80204008:	2781                	sext.w	a5,a5
    8020400a:	873e                	mv	a4,a5
    8020400c:	1f8617b7          	lui	a5,0x1f861
    80204010:	07a6                	slli	a5,a5,0x9
    80204012:	0791                	addi	a5,a5,4 # 1f861004 <_entry-0x6099effc>
    80204014:	97ba                	add	a5,a5,a4
    80204016:	873e                	mv	a4,a5
    80204018:	fdc42783          	lw	a5,-36(s0)
    8020401c:	c31c                	sw	a5,0(a4)
#endif

#ifdef DEBUG
    // printf("plic_complete, irq = %d\n", irq);
#endif
    8020401e:	0001                	nop
    80204020:	70a2                	ld	ra,40(sp)
    80204022:	7402                	ld	s0,32(sp)
    80204024:	6145                	addi	sp,sp,48
    80204026:	8082                	ret

0000000080204028 <w_satp>:
w_satp(address_t satp_data) {
    80204028:	1101                	addi	sp,sp,-32
    8020402a:	ec22                	sd	s0,24(sp)
    8020402c:	1000                	addi	s0,sp,32
    8020402e:	fea43423          	sd	a0,-24(s0)
    asm volatile("csrw satp, %0"
    80204032:	fe843783          	ld	a5,-24(s0)
    80204036:	18079073          	csrw	satp,a5
}
    8020403a:	0001                	nop
    8020403c:	6462                	ld	s0,24(sp)
    8020403e:	6105                	addi	sp,sp,32
    80204040:	8082                	ret

0000000080204042 <sfenve_vma>:
sfenve_vma() {
    80204042:	1141                	addi	sp,sp,-16
    80204044:	e422                	sd	s0,8(sp)
    80204046:	0800                	addi	s0,sp,16
    asm volatile("sfence.vma");
    80204048:	12000073          	sfence.vma
}
    8020404c:	0001                	nop
    8020404e:	6422                	ld	s0,8(sp)
    80204050:	0141                	addi	sp,sp,16
    80204052:	8082                	ret

0000000080204054 <sysproc_exit>:
#include "fs/file.h"

extern dirent_t root;

void
sysproc_exit(int status) {
    80204054:	7179                	addi	sp,sp,-48
    80204056:	f406                	sd	ra,40(sp)
    80204058:	f022                	sd	s0,32(sp)
    8020405a:	1800                	addi	s0,sp,48
    8020405c:	87aa                	mv	a5,a0
    8020405e:	fcf42e23          	sw	a5,-36(s0)
    proc_t* p = getCurrentProc();
    80204062:	ffffe097          	auipc	ra,0xffffe
    80204066:	b6c080e7          	jalr	-1172(ra) # 80201bce <getCurrentProc>
    8020406a:	fea43423          	sd	a0,-24(s0)
    //         file_t *fd = p->openFiles[i];
    //         // __file_close(fd);
    //         p->openFiles[i] = 0;
    //     }
    // }
    p->openFiles[STDIN] = (file_t*)STDIN_PTR;
    8020406e:	fe843783          	ld	a5,-24(s0)
    80204072:	4705                	li	a4,1
    80204074:	171e                	slli	a4,a4,0x27
    80204076:	ffd8                	sd	a4,184(a5)
    p->openFiles[STDOUT] = (file_t*)STDOUT_PTR;
    80204078:	fe843783          	ld	a5,-24(s0)
    8020407c:	4705                	li	a4,1
    8020407e:	1722                	slli	a4,a4,0x28
    80204080:	e3f8                	sd	a4,192(a5)
    p->openFiles[STDERR] = (file_t*)STDERR_PTR;
    80204082:	fe843783          	ld	a5,-24(s0)
    80204086:	4705                	li	a4,1
    80204088:	1726                	slli	a4,a4,0x29
    8020408a:	e7f8                	sd	a4,200(a5)
    if (p->cwd != &root) {
    8020408c:	fe843783          	ld	a5,-24(s0)
    80204090:	7bd8                	ld	a4,176(a5)
    80204092:	00327797          	auipc	a5,0x327
    80204096:	f7678793          	addi	a5,a5,-138 # 8052b008 <root>
    8020409a:	02f70163          	beq	a4,a5,802040bc <sysproc_exit+0x68>
        __fat32_put(p->cwd);
    8020409e:	fe843783          	ld	a5,-24(s0)
    802040a2:	7bdc                	ld	a5,176(a5)
    802040a4:	853e                	mv	a0,a5
    802040a6:	00002097          	auipc	ra,0x2
    802040aa:	6e8080e7          	jalr	1768(ra) # 8020678e <__fat32_put>
        p->cwd = &root;
    802040ae:	fe843783          	ld	a5,-24(s0)
    802040b2:	00327717          	auipc	a4,0x327
    802040b6:	f5670713          	addi	a4,a4,-170 # 8052b008 <root>
    802040ba:	fbd8                	sd	a4,176(a5)
    }
    if (p->isForked) {
    802040bc:	fe843783          	ld	a5,-24(s0)
    802040c0:	5907d783          	lhu	a5,1424(a5)
    802040c4:	c3dd                	beqz	a5,8020416a <sysproc_exit+0x116>
        spinlock_acquire(&p->lk);
    802040c6:	fe843783          	ld	a5,-24(s0)
    802040ca:	56878793          	addi	a5,a5,1384
    802040ce:	853e                	mv	a0,a5
    802040d0:	00001097          	auipc	ra,0x1
    802040d4:	882080e7          	jalr	-1918(ra) # 80204952 <spinlock_acquire>
        proc_t* parent_p = p->parent;
    802040d8:	fe843783          	ld	a5,-24(s0)
    802040dc:	5807b783          	ld	a5,1408(a5)
    802040e0:	fef43023          	sd	a5,-32(s0)
        spinlock_release(&p->lk);
    802040e4:	fe843783          	ld	a5,-24(s0)
    802040e8:	56878793          	addi	a5,a5,1384
    802040ec:	853e                	mv	a0,a5
    802040ee:	00001097          	auipc	ra,0x1
    802040f2:	8da080e7          	jalr	-1830(ra) # 802049c8 <spinlock_release>
        spinlock_acquire(&parent_p->lk);
    802040f6:	fe043783          	ld	a5,-32(s0)
    802040fa:	56878793          	addi	a5,a5,1384
    802040fe:	853e                	mv	a0,a5
    80204100:	00001097          	auipc	ra,0x1
    80204104:	852080e7          	jalr	-1966(ra) # 80204952 <spinlock_acquire>
        spinlock_acquire(&p->lk);
    80204108:	fe843783          	ld	a5,-24(s0)
    8020410c:	56878793          	addi	a5,a5,1384
    80204110:	853e                	mv	a0,a5
    80204112:	00001097          	auipc	ra,0x1
    80204116:	840080e7          	jalr	-1984(ra) # 80204952 <spinlock_acquire>
        reparent(p);
    8020411a:	fe843503          	ld	a0,-24(s0)
    8020411e:	ffffe097          	auipc	ra,0xffffe
    80204122:	5ea080e7          	jalr	1514(ra) # 80202708 <reparent>
        proc_wakeup(parent_p);
    80204126:	fe043503          	ld	a0,-32(s0)
    8020412a:	ffffe097          	auipc	ra,0xffffe
    8020412e:	312080e7          	jalr	786(ra) # 8020243c <proc_wakeup>
        p->xstatus = status;
    80204132:	fdc42703          	lw	a4,-36(s0)
    80204136:	fe843783          	ld	a5,-24(s0)
    8020413a:	c798                	sw	a4,8(a5)
        p->state = ZOMBIE;
    8020413c:	fe843783          	ld	a5,-24(s0)
    80204140:	4715                	li	a4,5
    80204142:	c398                	sw	a4,0(a5)
        spinlock_release(&parent_p->lk);
    80204144:	fe043783          	ld	a5,-32(s0)
    80204148:	56878793          	addi	a5,a5,1384
    8020414c:	853e                	mv	a0,a5
    8020414e:	00001097          	auipc	ra,0x1
    80204152:	87a080e7          	jalr	-1926(ra) # 802049c8 <spinlock_release>
        spinlock_release(&p->lk);
    80204156:	fe843783          	ld	a5,-24(s0)
    8020415a:	56878793          	addi	a5,a5,1384
    8020415e:	853e                	mv	a0,a5
    80204160:	00001097          	auipc	ra,0x1
    80204164:	868080e7          	jalr	-1944(ra) # 802049c8 <spinlock_release>
    80204168:	a825                	j	802041a0 <sysproc_exit+0x14c>
    } else {
        spinlock_acquire(&p->lk);
    8020416a:	fe843783          	ld	a5,-24(s0)
    8020416e:	56878793          	addi	a5,a5,1384
    80204172:	853e                	mv	a0,a5
    80204174:	00000097          	auipc	ra,0x0
    80204178:	7de080e7          	jalr	2014(ra) # 80204952 <spinlock_acquire>
        p->xstatus = status;
    8020417c:	fdc42703          	lw	a4,-36(s0)
    80204180:	fe843783          	ld	a5,-24(s0)
    80204184:	c798                	sw	a4,8(a5)
        p->state = ZOMBIE;
    80204186:	fe843783          	ld	a5,-24(s0)
    8020418a:	4715                	li	a4,5
    8020418c:	c398                	sw	a4,0(a5)
        spinlock_release(&p->lk);
    8020418e:	fe843783          	ld	a5,-24(s0)
    80204192:	56878793          	addi	a5,a5,1384
    80204196:	853e                	mv	a0,a5
    80204198:	00001097          	auipc	ra,0x1
    8020419c:	830080e7          	jalr	-2000(ra) # 802049c8 <spinlock_release>
    }
    __DEBUG_INFO(sysproc_exit() over);
    802041a0:	00007517          	auipc	a0,0x7
    802041a4:	2a050513          	addi	a0,a0,672 # 8020b440 <etext+0x440>
    802041a8:	ffffe097          	auipc	ra,0xffffe
    802041ac:	74a080e7          	jalr	1866(ra) # 802028f2 <printf>
    sched();
    802041b0:	ffffe097          	auipc	ra,0xffffe
    802041b4:	10a080e7          	jalr	266(ra) # 802022ba <sched>
}
    802041b8:	0001                	nop
    802041ba:	70a2                	ld	ra,40(sp)
    802041bc:	7402                	ld	s0,32(sp)
    802041be:	6145                	addi	sp,sp,48
    802041c0:	8082                	ret

00000000802041c2 <sysproc_getpid>:

pid_t
sysproc_getpid(void) {
    802041c2:	1141                	addi	sp,sp,-16
    802041c4:	e406                	sd	ra,8(sp)
    802041c6:	e022                	sd	s0,0(sp)
    802041c8:	0800                	addi	s0,sp,16
    return getCurrentProc()->pid;
    802041ca:	ffffe097          	auipc	ra,0xffffe
    802041ce:	a04080e7          	jalr	-1532(ra) # 80201bce <getCurrentProc>
    802041d2:	87aa                	mv	a5,a0
    802041d4:	47dc                	lw	a5,12(a5)
}    
    802041d6:	853e                	mv	a0,a5
    802041d8:	60a2                	ld	ra,8(sp)
    802041da:	6402                	ld	s0,0(sp)
    802041dc:	0141                	addi	sp,sp,16
    802041de:	8082                	ret

00000000802041e0 <sysproc_getppid>:


pid_t
sysproc_getppid(void) {
    802041e0:	1101                	addi	sp,sp,-32
    802041e2:	ec06                	sd	ra,24(sp)
    802041e4:	e822                	sd	s0,16(sp)
    802041e6:	1000                	addi	s0,sp,32
    proc_t* p = getCurrentProc();
    802041e8:	ffffe097          	auipc	ra,0xffffe
    802041ec:	9e6080e7          	jalr	-1562(ra) # 80201bce <getCurrentProc>
    802041f0:	fea43423          	sd	a0,-24(s0)
    if (p->parent) {
    802041f4:	fe843783          	ld	a5,-24(s0)
    802041f8:	5807b783          	ld	a5,1408(a5)
    802041fc:	c799                	beqz	a5,8020420a <sysproc_getppid+0x2a>
        return p->parent->pid;
    802041fe:	fe843783          	ld	a5,-24(s0)
    80204202:	5807b783          	ld	a5,1408(a5)
    80204206:	47dc                	lw	a5,12(a5)
    80204208:	a011                	j	8020420c <sysproc_getppid+0x2c>
    }
    return 0;
    8020420a:	4781                	li	a5,0
}
    8020420c:	853e                	mv	a0,a5
    8020420e:	60e2                	ld	ra,24(sp)
    80204210:	6442                	ld	s0,16(sp)
    80204212:	6105                	addi	sp,sp,32
    80204214:	8082                	ret

0000000080204216 <sysproc_clone>:

pid_t
sysproc_clone(uint64_t flags, void* stack, pid_t ptid, uint64_t tls, pid_t ctid) {
    80204216:	7179                	addi	sp,sp,-48
    80204218:	f406                	sd	ra,40(sp)
    8020421a:	f022                	sd	s0,32(sp)
    8020421c:	1800                	addi	s0,sp,48
    8020421e:	fea43423          	sd	a0,-24(s0)
    80204222:	feb43023          	sd	a1,-32(s0)
    80204226:	87b2                	mv	a5,a2
    80204228:	fcd43823          	sd	a3,-48(s0)
    8020422c:	fcf42e23          	sw	a5,-36(s0)
    80204230:	87ba                	mv	a5,a4
    80204232:	fcf42c23          	sw	a5,-40(s0)
    if(flags == SIGCHLD)
    80204236:	fe843703          	ld	a4,-24(s0)
    8020423a:	47c5                	li	a5,17
    8020423c:	00f71663          	bne	a4,a5,80204248 <sysproc_clone+0x32>
    {
        fork();
    80204240:	ffffe097          	auipc	ra,0xffffe
    80204244:	460080e7          	jalr	1120(ra) # 802026a0 <fork>
    }
    else
    {
        
    }
}
    80204248:	0001                	nop
    8020424a:	853e                	mv	a0,a5
    8020424c:	70a2                	ld	ra,40(sp)
    8020424e:	7402                	ld	s0,32(sp)
    80204250:	6145                	addi	sp,sp,48
    80204252:	8082                	ret

0000000080204254 <sysproc_execve>:

int
sysproc_execve(char* path, char* argv, char* envp) {
    80204254:	7139                	addi	sp,sp,-64
    80204256:	fc06                	sd	ra,56(sp)
    80204258:	f822                	sd	s0,48(sp)
    8020425a:	0080                	addi	s0,sp,64
    8020425c:	fca43c23          	sd	a0,-40(s0)
    80204260:	fcb43823          	sd	a1,-48(s0)
    80204264:	fcc43423          	sd	a2,-56(s0)
    proc_t* p = getCurrentProc();
    80204268:	ffffe097          	auipc	ra,0xffffe
    8020426c:	966080e7          	jalr	-1690(ra) # 80201bce <getCurrentProc>
    80204270:	fea43423          	sd	a0,-24(s0)
    elf_load(p, path);
    80204274:	fd843583          	ld	a1,-40(s0)
    80204278:	fe843503          	ld	a0,-24(s0)
    8020427c:	ffffd097          	auipc	ra,0xffffd
    80204280:	374080e7          	jalr	884(ra) # 802015f0 <elf_load>
    p->trapFrame->sp = p->size;
    80204284:	fe843783          	ld	a5,-24(s0)
    80204288:	779c                	ld	a5,40(a5)
    8020428a:	fe843703          	ld	a4,-24(s0)
    8020428e:	58873703          	ld	a4,1416(a4)
    80204292:	fb98                	sd	a4,48(a5)
    // p->trapFrame->a1 = sp ? why
    p->heap = NULL;
    80204294:	fe843783          	ld	a5,-24(s0)
    80204298:	5807bc23          	sd	zero,1432(a5)
    // TODO: fs
    w_satp(PAGE_TABLE_SHIFT(p->kpageTable));
    8020429c:	fe843783          	ld	a5,-24(s0)
    802042a0:	739c                	ld	a5,32(a5)
    802042a2:	00c7d713          	srli	a4,a5,0xc
    802042a6:	57fd                	li	a5,-1
    802042a8:	17fe                	slli	a5,a5,0x3f
    802042aa:	8fd9                	or	a5,a5,a4
    802042ac:	853e                	mv	a0,a5
    802042ae:	00000097          	auipc	ra,0x0
    802042b2:	d7a080e7          	jalr	-646(ra) # 80204028 <w_satp>
    sfenve_vma();
    802042b6:	00000097          	auipc	ra,0x0
    802042ba:	d8c080e7          	jalr	-628(ra) # 80204042 <sfenve_vma>
    return 0;
    802042be:	4781                	li	a5,0
}
    802042c0:	853e                	mv	a0,a5
    802042c2:	70e2                	ld	ra,56(sp)
    802042c4:	7442                	ld	s0,48(sp)
    802042c6:	6121                	addi	sp,sp,64
    802042c8:	8082                	ret

00000000802042ca <sysproc_wait4>:

pid_t
sysproc_wait4(pid_t pid, int* status, int options) {
    802042ca:	1101                	addi	sp,sp,-32
    802042cc:	ec06                	sd	ra,24(sp)
    802042ce:	e822                	sd	s0,16(sp)
    802042d0:	1000                	addi	s0,sp,32
    802042d2:	87aa                	mv	a5,a0
    802042d4:	feb43023          	sd	a1,-32(s0)
    802042d8:	8732                	mv	a4,a2
    802042da:	fef42623          	sw	a5,-20(s0)
    802042de:	87ba                	mv	a5,a4
    802042e0:	fef42423          	sw	a5,-24(s0)
    return wait(pid);
    802042e4:	fec42783          	lw	a5,-20(s0)
    802042e8:	853e                	mv	a0,a5
    802042ea:	ffffe097          	auipc	ra,0xffffe
    802042ee:	1b0080e7          	jalr	432(ra) # 8020249a <wait>
    802042f2:	87aa                	mv	a5,a0
}
    802042f4:	853e                	mv	a0,a5
    802042f6:	60e2                	ld	ra,24(sp)
    802042f8:	6442                	ld	s0,16(sp)
    802042fa:	6105                	addi	sp,sp,32
    802042fc:	8082                	ret

00000000802042fe <sysproc_sched_yield>:

int
sysproc_sched_yield(void) {
    802042fe:	1141                	addi	sp,sp,-16
    80204300:	e406                	sd	ra,8(sp)
    80204302:	e022                	sd	s0,0(sp)
    80204304:	0800                	addi	s0,sp,16
    yield();
    80204306:	ffffe097          	auipc	ra,0xffffe
    8020430a:	f52080e7          	jalr	-174(ra) # 80202258 <yield>
    return 1;
    8020430e:	4785                	li	a5,1
}
    80204310:	853e                	mv	a0,a5
    80204312:	60a2                	ld	ra,8(sp)
    80204314:	6402                	ld	s0,0(sp)
    80204316:	0141                	addi	sp,sp,16
    80204318:	8082                	ret

000000008020431a <sysproc_times>:

address_t sysproc_times(void * mytimes)
{
    8020431a:	7179                	addi	sp,sp,-48
    8020431c:	f406                	sd	ra,40(sp)
    8020431e:	f022                	sd	s0,32(sp)
    80204320:	1800                	addi	s0,sp,48
    80204322:	fca43c23          	sd	a0,-40(s0)
    tms_t *user = (tms_t *)mytimes;
    80204326:	fd843783          	ld	a5,-40(s0)
    8020432a:	fef43423          	sd	a5,-24(s0)
    proc_t *p = getCurrentProc();
    8020432e:	ffffe097          	auipc	ra,0xffffe
    80204332:	8a0080e7          	jalr	-1888(ra) # 80201bce <getCurrentProc>
    80204336:	fea43023          	sd	a0,-32(s0)
    user->tms_stime = p->tms.tms_stime;
    8020433a:	fe043783          	ld	a5,-32(s0)
    8020433e:	5a87b703          	ld	a4,1448(a5)
    80204342:	fe843783          	ld	a5,-24(s0)
    80204346:	e798                	sd	a4,8(a5)
    user->tms_cstime = p->tms.tms_cstime;
    80204348:	fe043783          	ld	a5,-32(s0)
    8020434c:	5b87b703          	ld	a4,1464(a5)
    80204350:	fe843783          	ld	a5,-24(s0)
    80204354:	ef98                	sd	a4,24(a5)
    user->tms_cutime = p->tms.tms_cutime;
    80204356:	fe043783          	ld	a5,-32(s0)
    8020435a:	5b07b703          	ld	a4,1456(a5)
    8020435e:	fe843783          	ld	a5,-24(s0)
    80204362:	eb98                	sd	a4,16(a5)
    user->tms_utime = p->tms.tms_utime;
    80204364:	fe043783          	ld	a5,-32(s0)
    80204368:	5a07b703          	ld	a4,1440(a5)
    8020436c:	fe843783          	ld	a5,-24(s0)
    80204370:	e398                	sd	a4,0(a5)
    return (address_t)mytimes;
    80204372:	fd843783          	ld	a5,-40(s0)
}
    80204376:	853e                	mv	a0,a5
    80204378:	70a2                	ld	ra,40(sp)
    8020437a:	7402                	ld	s0,32(sp)
    8020437c:	6145                	addi	sp,sp,48
    8020437e:	8082                	ret

0000000080204380 <sysproc_nanosleep>:

uint64_t sysproc_nanosleep(void)
{
    80204380:	1141                	addi	sp,sp,-16
    80204382:	e422                	sd	s0,8(sp)
    80204384:	0800                	addi	s0,sp,16

}
    80204386:	0001                	nop
    80204388:	853e                	mv	a0,a5
    8020438a:	6422                	ld	s0,8(sp)
    8020438c:	0141                	addi	sp,sp,16
    8020438e:	8082                	ret

0000000080204390 <sysmm_brk>:
#include "proc.h"
#include "fs/fat32.h"
#include "fs/file.h"
#include "string.h"
address_t sysmm_brk(address_t brk)
{
    80204390:	7179                	addi	sp,sp,-48
    80204392:	f406                	sd	ra,40(sp)
    80204394:	f022                	sd	s0,32(sp)
    80204396:	1800                	addi	s0,sp,48
    80204398:	fca43c23          	sd	a0,-40(s0)
    proc_t *p = getCurrentProc();
    8020439c:	ffffe097          	auipc	ra,0xffffe
    802043a0:	832080e7          	jalr	-1998(ra) # 80201bce <getCurrentProc>
    802043a4:	fea43423          	sd	a0,-24(s0)
    if(p->heap == NULL)
    802043a8:	fe843783          	ld	a5,-24(s0)
    802043ac:	5987b783          	ld	a5,1432(a5)
    802043b0:	e7b9                	bnez	a5,802043fe <sysmm_brk+0x6e>
    {
        void * mem = kalloc();
    802043b2:	ffffc097          	auipc	ra,0xffffc
    802043b6:	3c2080e7          	jalr	962(ra) # 80200774 <kalloc>
    802043ba:	fea43023          	sd	a0,-32(s0)
        create_pages_map(p->upageTable, (address_t)PRO_SIZE, (address_t)mem, PAGE_SIZE, PTE_R | PTE_W | PTE_U);
    802043be:	fe843783          	ld	a5,-24(s0)
    802043c2:	6f9c                	ld	a5,24(a5)
    802043c4:	fe043603          	ld	a2,-32(s0)
    802043c8:	4759                	li	a4,22
    802043ca:	6685                	lui	a3,0x1
    802043cc:	6595                	lui	a1,0x5
    802043ce:	853e                	mv	a0,a5
    802043d0:	ffffc097          	auipc	ra,0xffffc
    802043d4:	5c8080e7          	jalr	1480(ra) # 80200998 <create_pages_map>
        create_pages_map(p->kpageTable, (address_t)PRO_SIZE, (address_t)mem, PAGE_SIZE, PTE_R | PTE_W);
    802043d8:	fe843783          	ld	a5,-24(s0)
    802043dc:	739c                	ld	a5,32(a5)
    802043de:	fe043603          	ld	a2,-32(s0)
    802043e2:	4719                	li	a4,6
    802043e4:	6685                	lui	a3,0x1
    802043e6:	6595                	lui	a1,0x5
    802043e8:	853e                	mv	a0,a5
    802043ea:	ffffc097          	auipc	ra,0xffffc
    802043ee:	5ae080e7          	jalr	1454(ra) # 80200998 <create_pages_map>
        p->heap = mem;
    802043f2:	fe843783          	ld	a5,-24(s0)
    802043f6:	fe043703          	ld	a4,-32(s0)
    802043fa:	58e7bc23          	sd	a4,1432(a5)
    }
    p->heap = (void *)((address_t)p->heap + brk);
    802043fe:	fe843783          	ld	a5,-24(s0)
    80204402:	5987b783          	ld	a5,1432(a5)
    80204406:	873e                	mv	a4,a5
    80204408:	fd843783          	ld	a5,-40(s0)
    8020440c:	97ba                	add	a5,a5,a4
    8020440e:	873e                	mv	a4,a5
    80204410:	fe843783          	ld	a5,-24(s0)
    80204414:	58e7bc23          	sd	a4,1432(a5)
    return (address_t)p->heap;
    80204418:	fe843783          	ld	a5,-24(s0)
    8020441c:	5987b783          	ld	a5,1432(a5)
}
    80204420:	853e                	mv	a0,a5
    80204422:	70a2                	ld	ra,40(sp)
    80204424:	7402                	ld	s0,32(sp)
    80204426:	6145                	addi	sp,sp,48
    80204428:	8082                	ret

000000008020442a <sysmm_munmap>:

int sysmm_munmap(void *start, size_t len)
{
    8020442a:	7179                	addi	sp,sp,-48
    8020442c:	f406                	sd	ra,40(sp)
    8020442e:	f022                	sd	s0,32(sp)
    80204430:	1800                	addi	s0,sp,48
    80204432:	fca43c23          	sd	a0,-40(s0)
    80204436:	fcb43823          	sd	a1,-48(s0)
    size_t size = sizeof(long int) / sizeof(char);
    8020443a:	47a1                	li	a5,8
    8020443c:	fef43423          	sd	a5,-24(s0)
    memset(start, 0, len * size);
    80204440:	fd043703          	ld	a4,-48(s0)
    80204444:	fe843783          	ld	a5,-24(s0)
    80204448:	02f707b3          	mul	a5,a4,a5
    8020444c:	863e                	mv	a2,a5
    8020444e:	4581                	li	a1,0
    80204450:	fd843503          	ld	a0,-40(s0)
    80204454:	ffffe097          	auipc	ra,0xffffe
    80204458:	6d2080e7          	jalr	1746(ra) # 80202b26 <memset>
    return 0;
    8020445c:	4781                	li	a5,0
}
    8020445e:	853e                	mv	a0,a5
    80204460:	70a2                	ld	ra,40(sp)
    80204462:	7402                	ld	s0,32(sp)
    80204464:	6145                	addi	sp,sp,48
    80204466:	8082                	ret

0000000080204468 <sysmm_mmap>:

address_t sysmm_mmap(void *start, size_t len, int prot, int flags, int fd, uint64_t off)
{
    80204468:	711d                	addi	sp,sp,-96
    8020446a:	ec86                	sd	ra,88(sp)
    8020446c:	e8a2                	sd	s0,80(sp)
    8020446e:	1080                	addi	s0,sp,96
    80204470:	fca43423          	sd	a0,-56(s0)
    80204474:	fcb43023          	sd	a1,-64(s0)
    80204478:	faf43423          	sd	a5,-88(s0)
    8020447c:	87b2                	mv	a5,a2
    8020447e:	faf42e23          	sw	a5,-68(s0)
    80204482:	87b6                	mv	a5,a3
    80204484:	faf42c23          	sw	a5,-72(s0)
    80204488:	87ba                	mv	a5,a4
    8020448a:	faf42a23          	sw	a5,-76(s0)
    //TODO: get pa; deal with fd/off; prot/flags
    // extern pageTable_t kernel_pageTable;
    // address_t pa;
 
    // create_pages_map(kernel_pageTable, (address_t)start, (address_t)pa, len, PTE_R | PTE_W);
    proc_t *p = getCurrentProc();
    8020448e:	ffffd097          	auipc	ra,0xffffd
    80204492:	740080e7          	jalr	1856(ra) # 80201bce <getCurrentProc>
    80204496:	fea43423          	sd	a0,-24(s0)
    file_t *f = p->openFiles[fd];
    8020449a:	fe843703          	ld	a4,-24(s0)
    8020449e:	fb442783          	lw	a5,-76(s0)
    802044a2:	07d9                	addi	a5,a5,22
    802044a4:	078e                	slli	a5,a5,0x3
    802044a6:	97ba                	add	a5,a5,a4
    802044a8:	679c                	ld	a5,8(a5)
    802044aa:	fef43023          	sd	a5,-32(s0)
    size_t size = sizeof(long int) / sizeof(char);
    802044ae:	47a1                	li	a5,8
    802044b0:	fcf43c23          	sd	a5,-40(s0)
    __fat32_read((f->d_entry), 0, start, 0, len * size);
    802044b4:	fe043783          	ld	a5,-32(s0)
    802044b8:	7788                	ld	a0,40(a5)
    802044ba:	fc043703          	ld	a4,-64(s0)
    802044be:	fd843783          	ld	a5,-40(s0)
    802044c2:	02f707b3          	mul	a5,a4,a5
    802044c6:	873e                	mv	a4,a5
    802044c8:	4681                	li	a3,0
    802044ca:	fc843603          	ld	a2,-56(s0)
    802044ce:	4581                	li	a1,0
    802044d0:	00001097          	auipc	ra,0x1
    802044d4:	736080e7          	jalr	1846(ra) # 80205c06 <__fat32_read>
    return 0;
    802044d8:	4781                	li	a5,0
    802044da:	853e                	mv	a0,a5
    802044dc:	60e6                	ld	ra,88(sp)
    802044de:	6446                	ld	s0,80(sp)
    802044e0:	6125                	addi	sp,sp,96
    802044e2:	8082                	ret

00000000802044e4 <monitor_init>:
#include "lock/monitor.h"
#include "assert.h"
#include "mmu.h"

void
monitor_init(monitor_t* m, size_t cvNum) {
    802044e4:	7179                	addi	sp,sp,-48
    802044e6:	f406                	sd	ra,40(sp)
    802044e8:	f022                	sd	s0,32(sp)
    802044ea:	1800                	addi	s0,sp,48
    802044ec:	fca43c23          	sd	a0,-40(s0)
    802044f0:	fcb43823          	sd	a1,-48(s0)
    assert(cvNum > 0);
    802044f4:	fd043783          	ld	a5,-48(s0)
    802044f8:	eb89                	bnez	a5,8020450a <monitor_init+0x26>
    802044fa:	00007517          	auipc	a0,0x7
    802044fe:	f5e50513          	addi	a0,a0,-162 # 8020b458 <etext+0x458>
    80204502:	ffffe097          	auipc	ra,0xffffe
    80204506:	602080e7          	jalr	1538(ra) # 80202b04 <panic>
    semaphore_init(&(m->mutex), 1);
    8020450a:	fd843783          	ld	a5,-40(s0)
    8020450e:	4585                	li	a1,1
    80204510:	853e                	mv	a0,a5
    80204512:	00000097          	auipc	ra,0x0
    80204516:	1ac080e7          	jalr	428(ra) # 802046be <semaphore_init>
    semaphore_init(&(m->next), 0);
    8020451a:	fd843783          	ld	a5,-40(s0)
    8020451e:	07e1                	addi	a5,a5,24
    80204520:	4581                	li	a1,0
    80204522:	853e                	mv	a0,a5
    80204524:	00000097          	auipc	ra,0x0
    80204528:	19a080e7          	jalr	410(ra) # 802046be <semaphore_init>
    m->nextCount = 0;
    8020452c:	fd843783          	ld	a5,-40(s0)
    80204530:	0207a823          	sw	zero,48(a5)
    m->cv = kmalloc(sizeof(condvar_t) * cvNum);
    80204534:	fd043703          	ld	a4,-48(s0)
    80204538:	87ba                	mv	a5,a4
    8020453a:	078a                	slli	a5,a5,0x2
    8020453c:	97ba                	add	a5,a5,a4
    8020453e:	078e                	slli	a5,a5,0x3
    80204540:	853e                	mv	a0,a5
    80204542:	ffffc097          	auipc	ra,0xffffc
    80204546:	71e080e7          	jalr	1822(ra) # 80200c60 <kmalloc>
    8020454a:	872a                	mv	a4,a0
    8020454c:	fd843783          	ld	a5,-40(s0)
    80204550:	ff98                	sd	a4,56(a5)
    assert(m->cv != NULL);
    80204552:	fd843783          	ld	a5,-40(s0)
    80204556:	7f9c                	ld	a5,56(a5)
    80204558:	eb89                	bnez	a5,8020456a <monitor_init+0x86>
    8020455a:	00007517          	auipc	a0,0x7
    8020455e:	f1e50513          	addi	a0,a0,-226 # 8020b478 <etext+0x478>
    80204562:	ffffe097          	auipc	ra,0xffffe
    80204566:	5a2080e7          	jalr	1442(ra) # 80202b04 <panic>
    for (int i = 0; i < cvNum; ++i) {
    8020456a:	fe042623          	sw	zero,-20(s0)
    8020456e:	a8b9                	j	802045cc <monitor_init+0xe8>
        m->cv[i].count = 0;
    80204570:	fd843783          	ld	a5,-40(s0)
    80204574:	7f94                	ld	a3,56(a5)
    80204576:	fec42703          	lw	a4,-20(s0)
    8020457a:	87ba                	mv	a5,a4
    8020457c:	078a                	slli	a5,a5,0x2
    8020457e:	97ba                	add	a5,a5,a4
    80204580:	078e                	slli	a5,a5,0x3
    80204582:	97b6                	add	a5,a5,a3
    80204584:	0007ac23          	sw	zero,24(a5)
        semaphore_init(&(m->cv[i].sem), 0);
    80204588:	fd843783          	ld	a5,-40(s0)
    8020458c:	7f94                	ld	a3,56(a5)
    8020458e:	fec42703          	lw	a4,-20(s0)
    80204592:	87ba                	mv	a5,a4
    80204594:	078a                	slli	a5,a5,0x2
    80204596:	97ba                	add	a5,a5,a4
    80204598:	078e                	slli	a5,a5,0x3
    8020459a:	97b6                	add	a5,a5,a3
    8020459c:	4581                	li	a1,0
    8020459e:	853e                	mv	a0,a5
    802045a0:	00000097          	auipc	ra,0x0
    802045a4:	11e080e7          	jalr	286(ra) # 802046be <semaphore_init>
        m->cv[i].owner = m;
    802045a8:	fd843783          	ld	a5,-40(s0)
    802045ac:	7f94                	ld	a3,56(a5)
    802045ae:	fec42703          	lw	a4,-20(s0)
    802045b2:	87ba                	mv	a5,a4
    802045b4:	078a                	slli	a5,a5,0x2
    802045b6:	97ba                	add	a5,a5,a4
    802045b8:	078e                	slli	a5,a5,0x3
    802045ba:	97b6                	add	a5,a5,a3
    802045bc:	fd843703          	ld	a4,-40(s0)
    802045c0:	f398                	sd	a4,32(a5)
    for (int i = 0; i < cvNum; ++i) {
    802045c2:	fec42783          	lw	a5,-20(s0)
    802045c6:	2785                	addiw	a5,a5,1
    802045c8:	fef42623          	sw	a5,-20(s0)
    802045cc:	fec42783          	lw	a5,-20(s0)
    802045d0:	fd043703          	ld	a4,-48(s0)
    802045d4:	f8e7eee3          	bltu	a5,a4,80204570 <monitor_init+0x8c>
    }
}
    802045d8:	0001                	nop
    802045da:	0001                	nop
    802045dc:	70a2                	ld	ra,40(sp)
    802045de:	7402                	ld	s0,32(sp)
    802045e0:	6145                	addi	sp,sp,48
    802045e2:	8082                	ret

00000000802045e4 <cond_signal>:

void
cond_signal(condvar_t* cv) {
    802045e4:	7179                	addi	sp,sp,-48
    802045e6:	f406                	sd	ra,40(sp)
    802045e8:	f022                	sd	s0,32(sp)
    802045ea:	1800                	addi	s0,sp,48
    802045ec:	fca43c23          	sd	a0,-40(s0)
    if (cv->count > 0) {
    802045f0:	fd843783          	ld	a5,-40(s0)
    802045f4:	4f9c                	lw	a5,24(a5)
    802045f6:	04f05863          	blez	a5,80204646 <cond_signal+0x62>
        monitor_t* m = cv->owner;
    802045fa:	fd843783          	ld	a5,-40(s0)
    802045fe:	739c                	ld	a5,32(a5)
    80204600:	fef43423          	sd	a5,-24(s0)
        ++m->nextCount;
    80204604:	fe843783          	ld	a5,-24(s0)
    80204608:	5b9c                	lw	a5,48(a5)
    8020460a:	2785                	addiw	a5,a5,1
    8020460c:	0007871b          	sext.w	a4,a5
    80204610:	fe843783          	ld	a5,-24(s0)
    80204614:	db98                	sw	a4,48(a5)
        semaphore_release(&(cv->sem));
    80204616:	fd843783          	ld	a5,-40(s0)
    8020461a:	853e                	mv	a0,a5
    8020461c:	00000097          	auipc	ra,0x0
    80204620:	216080e7          	jalr	534(ra) # 80204832 <semaphore_release>
        semaphore_acquire(&(m->next));
    80204624:	fe843783          	ld	a5,-24(s0)
    80204628:	07e1                	addi	a5,a5,24
    8020462a:	853e                	mv	a0,a5
    8020462c:	00000097          	auipc	ra,0x0
    80204630:	22c080e7          	jalr	556(ra) # 80204858 <semaphore_acquire>
        --m->nextCount;
    80204634:	fe843783          	ld	a5,-24(s0)
    80204638:	5b9c                	lw	a5,48(a5)
    8020463a:	37fd                	addiw	a5,a5,-1
    8020463c:	0007871b          	sext.w	a4,a5
    80204640:	fe843783          	ld	a5,-24(s0)
    80204644:	db98                	sw	a4,48(a5)
    }
}
    80204646:	0001                	nop
    80204648:	70a2                	ld	ra,40(sp)
    8020464a:	7402                	ld	s0,32(sp)
    8020464c:	6145                	addi	sp,sp,48
    8020464e:	8082                	ret

0000000080204650 <cond_wait>:

void
cond_wait(condvar_t* cv) {
    80204650:	7179                	addi	sp,sp,-48
    80204652:	f406                	sd	ra,40(sp)
    80204654:	f022                	sd	s0,32(sp)
    80204656:	1800                	addi	s0,sp,48
    80204658:	fca43c23          	sd	a0,-40(s0)
    ++cv->count;
    8020465c:	fd843783          	ld	a5,-40(s0)
    80204660:	4f9c                	lw	a5,24(a5)
    80204662:	2785                	addiw	a5,a5,1
    80204664:	0007871b          	sext.w	a4,a5
    80204668:	fd843783          	ld	a5,-40(s0)
    8020466c:	cf98                	sw	a4,24(a5)
    monitor_t* m = cv->owner;
    8020466e:	fd843783          	ld	a5,-40(s0)
    80204672:	739c                	ld	a5,32(a5)
    80204674:	fef43423          	sd	a5,-24(s0)
    if (m->nextCount > 0)
    80204678:	fe843783          	ld	a5,-24(s0)
    8020467c:	5b9c                	lw	a5,48(a5)
    8020467e:	00f05b63          	blez	a5,80204694 <cond_wait+0x44>
        semaphore_release(&(m->next));
    80204682:	fe843783          	ld	a5,-24(s0)
    80204686:	07e1                	addi	a5,a5,24
    80204688:	853e                	mv	a0,a5
    8020468a:	00000097          	auipc	ra,0x0
    8020468e:	1a8080e7          	jalr	424(ra) # 80204832 <semaphore_release>
    80204692:	a801                	j	802046a2 <cond_wait+0x52>
    else
        semaphore_release(&(cv->sem));
    80204694:	fd843783          	ld	a5,-40(s0)
    80204698:	853e                	mv	a0,a5
    8020469a:	00000097          	auipc	ra,0x0
    8020469e:	198080e7          	jalr	408(ra) # 80204832 <semaphore_release>
    --cv->count;
    802046a2:	fd843783          	ld	a5,-40(s0)
    802046a6:	4f9c                	lw	a5,24(a5)
    802046a8:	37fd                	addiw	a5,a5,-1
    802046aa:	0007871b          	sext.w	a4,a5
    802046ae:	fd843783          	ld	a5,-40(s0)
    802046b2:	cf98                	sw	a4,24(a5)
    802046b4:	0001                	nop
    802046b6:	70a2                	ld	ra,40(sp)
    802046b8:	7402                	ld	s0,32(sp)
    802046ba:	6145                	addi	sp,sp,48
    802046bc:	8082                	ret

00000000802046be <semaphore_init>:
#include "lock/wait.h"

#include "lock/semaphore.h"

void
semaphore_init(semaphore_t* sem, int value) {
    802046be:	1101                	addi	sp,sp,-32
    802046c0:	ec06                	sd	ra,24(sp)
    802046c2:	e822                	sd	s0,16(sp)
    802046c4:	1000                	addi	s0,sp,32
    802046c6:	fea43423          	sd	a0,-24(s0)
    802046ca:	87ae                	mv	a5,a1
    802046cc:	fef42223          	sw	a5,-28(s0)
    sem->value = value;
    802046d0:	fe843783          	ld	a5,-24(s0)
    802046d4:	fe442703          	lw	a4,-28(s0)
    802046d8:	c398                	sw	a4,0(a5)
    waitQueue_init(&(sem->waitQueue));
    802046da:	fe843783          	ld	a5,-24(s0)
    802046de:	07a1                	addi	a5,a5,8
    802046e0:	853e                	mv	a0,a5
    802046e2:	00000097          	auipc	ra,0x0
    802046e6:	380080e7          	jalr	896(ra) # 80204a62 <waitQueue_init>
}
    802046ea:	0001                	nop
    802046ec:	60e2                	ld	ra,24(sp)
    802046ee:	6442                	ld	s0,16(sp)
    802046f0:	6105                	addi	sp,sp,32
    802046f2:	8082                	ret

00000000802046f4 <__semaphore_release>:

void
__semaphore_release(semaphore_t* sem, uint32_t waitState) {
    802046f4:	7179                	addi	sp,sp,-48
    802046f6:	f406                	sd	ra,40(sp)
    802046f8:	f022                	sd	s0,32(sp)
    802046fa:	1800                	addi	s0,sp,48
    802046fc:	fca43c23          	sd	a0,-40(s0)
    80204700:	87ae                	mv	a5,a1
    80204702:	fcf42a23          	sw	a5,-44(s0)
    // intr_off();
    {
        wait_t* wait = waitQueue_first(&(sem->waitQueue));
    80204706:	fd843783          	ld	a5,-40(s0)
    8020470a:	07a1                	addi	a5,a5,8
    8020470c:	853e                	mv	a0,a5
    8020470e:	00000097          	auipc	ra,0x0
    80204712:	608080e7          	jalr	1544(ra) # 80204d16 <waitQueue_first>
    80204716:	fea43423          	sd	a0,-24(s0)
        if (wait == NULL)
    8020471a:	fe843783          	ld	a5,-24(s0)
    8020471e:	eb99                	bnez	a5,80204734 <__semaphore_release+0x40>
            ++sem->value;
    80204720:	fd843783          	ld	a5,-40(s0)
    80204724:	439c                	lw	a5,0(a5)
    80204726:	2785                	addiw	a5,a5,1
    80204728:	0007871b          	sext.w	a4,a5
    8020472c:	fd843783          	ld	a5,-40(s0)
    80204730:	c398                	sw	a4,0(a5)
    80204732:	a025                	j	8020475a <__semaphore_release+0x66>
        else {
            assert(wait->proc->state = SLEEPING);  // TODO
    80204734:	fe843783          	ld	a5,-24(s0)
    80204738:	639c                	ld	a5,0(a5)
    8020473a:	4711                	li	a4,4
    8020473c:	c398                	sw	a4,0(a5)
            wakeup_wait(&(sem->waitQueue), wait, waitState, 1);
    8020473e:	fd843783          	ld	a5,-40(s0)
    80204742:	07a1                	addi	a5,a5,8
    80204744:	fd442703          	lw	a4,-44(s0)
    80204748:	4685                	li	a3,1
    8020474a:	863a                	mv	a2,a4
    8020474c:	fe843583          	ld	a1,-24(s0)
    80204750:	853e                	mv	a0,a5
    80204752:	00000097          	auipc	ra,0x0
    80204756:	6a8080e7          	jalr	1704(ra) # 80204dfa <wakeup_wait>
        }
    }
    // intr_on();
    intr_pop();  // TODO 正确的信号量应当如何实现
    8020475a:	fffff097          	auipc	ra,0xfffff
    8020475e:	614080e7          	jalr	1556(ra) # 80203d6e <intr_pop>
}
    80204762:	0001                	nop
    80204764:	70a2                	ld	ra,40(sp)
    80204766:	7402                	ld	s0,32(sp)
    80204768:	6145                	addi	sp,sp,48
    8020476a:	8082                	ret

000000008020476c <__semaphore_acquire>:

uint32_t
__semaphore_acquire(semaphore_t* sem, uint32_t waitState) {  // TODO 正确的信号量应当如何实现
    8020476c:	715d                	addi	sp,sp,-80
    8020476e:	e486                	sd	ra,72(sp)
    80204770:	e0a2                	sd	s0,64(sp)
    80204772:	0880                	addi	s0,sp,80
    80204774:	faa43c23          	sd	a0,-72(s0)
    80204778:	87ae                	mv	a5,a1
    8020477a:	faf42a23          	sw	a5,-76(s0)
    // intr_off();
    intr_push();
    8020477e:	fffff097          	auipc	ra,0xfffff
    80204782:	672080e7          	jalr	1650(ra) # 80203df0 <intr_push>
    if (sem->value > 0) {
    80204786:	fb843783          	ld	a5,-72(s0)
    8020478a:	439c                	lw	a5,0(a5)
    8020478c:	02f05163          	blez	a5,802047ae <__semaphore_acquire+0x42>
        --sem->value;
    80204790:	fb843783          	ld	a5,-72(s0)
    80204794:	439c                	lw	a5,0(a5)
    80204796:	37fd                	addiw	a5,a5,-1
    80204798:	0007871b          	sext.w	a4,a5
    8020479c:	fb843783          	ld	a5,-72(s0)
    802047a0:	c398                	sw	a4,0(a5)
        intr_on();
    802047a2:	fffff097          	auipc	ra,0xfffff
    802047a6:	57a080e7          	jalr	1402(ra) # 80203d1c <intr_on>
        return 0;
    802047aa:	4781                	li	a5,0
    802047ac:	a8b5                	j	80204828 <__semaphore_acquire+0xbc>
    }
    wait_t wait;
    wait_current_set(&(sem->waitQueue), &wait, waitState);
    802047ae:	fb843783          	ld	a5,-72(s0)
    802047b2:	07a1                	addi	a5,a5,8
    802047b4:	fb442683          	lw	a3,-76(s0)
    802047b8:	fc840713          	addi	a4,s0,-56
    802047bc:	8636                	mv	a2,a3
    802047be:	85ba                	mv	a1,a4
    802047c0:	853e                	mv	a0,a5
    802047c2:	00000097          	auipc	ra,0x0
    802047c6:	764080e7          	jalr	1892(ra) # 80204f26 <wait_current_set>
    intr_on();
    802047ca:	fffff097          	auipc	ra,0xfffff
    802047ce:	552080e7          	jalr	1362(ra) # 80203d1c <intr_on>

    sched();
    802047d2:	ffffe097          	auipc	ra,0xffffe
    802047d6:	ae8080e7          	jalr	-1304(ra) # 802022ba <sched>

    intr_off();
    802047da:	fffff097          	auipc	ra,0xfffff
    802047de:	51a080e7          	jalr	1306(ra) # 80203cf4 <intr_off>
    wait_current_del(&(sem->waitQueue), &wait);
    802047e2:	fc840793          	addi	a5,s0,-56
    802047e6:	853e                	mv	a0,a5
    802047e8:	00000097          	auipc	ra,0x0
    802047ec:	5d4080e7          	jalr	1492(ra) # 80204dbc <wait_isInQueue>
    802047f0:	87aa                	mv	a5,a0
    802047f2:	cf81                	beqz	a5,8020480a <__semaphore_acquire+0x9e>
    802047f4:	fb843783          	ld	a5,-72(s0)
    802047f8:	07a1                	addi	a5,a5,8
    802047fa:	fc840713          	addi	a4,s0,-56
    802047fe:	85ba                	mv	a1,a4
    80204800:	853e                	mv	a0,a5
    80204802:	00000097          	auipc	ra,0x0
    80204806:	34c080e7          	jalr	844(ra) # 80204b4e <waitQueue_del>
    intr_on();
    8020480a:	fffff097          	auipc	ra,0xfffff
    8020480e:	512080e7          	jalr	1298(ra) # 80203d1c <intr_on>

    if (wait.wakeupFlags != waitState)
    80204812:	fd042703          	lw	a4,-48(s0)
    80204816:	fb442783          	lw	a5,-76(s0)
    8020481a:	2781                	sext.w	a5,a5
    8020481c:	00e78563          	beq	a5,a4,80204826 <__semaphore_acquire+0xba>
        return wait.wakeupFlags;
    80204820:	fd042783          	lw	a5,-48(s0)
    80204824:	a011                	j	80204828 <__semaphore_acquire+0xbc>
    return 0;
    80204826:	4781                	li	a5,0
}
    80204828:	853e                	mv	a0,a5
    8020482a:	60a6                	ld	ra,72(sp)
    8020482c:	6406                	ld	s0,64(sp)
    8020482e:	6161                	addi	sp,sp,80
    80204830:	8082                	ret

0000000080204832 <semaphore_release>:

void
semaphore_release(semaphore_t* sem) {
    80204832:	1101                	addi	sp,sp,-32
    80204834:	ec06                	sd	ra,24(sp)
    80204836:	e822                	sd	s0,16(sp)
    80204838:	1000                	addi	s0,sp,32
    8020483a:	fea43423          	sd	a0,-24(s0)
    __semaphore_release(sem, WT_KSEM);
    8020483e:	10000593          	li	a1,256
    80204842:	fe843503          	ld	a0,-24(s0)
    80204846:	00000097          	auipc	ra,0x0
    8020484a:	eae080e7          	jalr	-338(ra) # 802046f4 <__semaphore_release>
}
    8020484e:	0001                	nop
    80204850:	60e2                	ld	ra,24(sp)
    80204852:	6442                	ld	s0,16(sp)
    80204854:	6105                	addi	sp,sp,32
    80204856:	8082                	ret

0000000080204858 <semaphore_acquire>:

void
semaphore_acquire(semaphore_t* sem) {
    80204858:	1101                	addi	sp,sp,-32
    8020485a:	ec06                	sd	ra,24(sp)
    8020485c:	e822                	sd	s0,16(sp)
    8020485e:	1000                	addi	s0,sp,32
    80204860:	fea43423          	sd	a0,-24(s0)
    assert(__semaphore_acquire(sem, WT_KSEM) == 0);
    80204864:	10000593          	li	a1,256
    80204868:	fe843503          	ld	a0,-24(s0)
    8020486c:	00000097          	auipc	ra,0x0
    80204870:	f00080e7          	jalr	-256(ra) # 8020476c <__semaphore_acquire>
    80204874:	87aa                	mv	a5,a0
    80204876:	2781                	sext.w	a5,a5
    80204878:	cb89                	beqz	a5,8020488a <semaphore_acquire+0x32>
    8020487a:	00007517          	auipc	a0,0x7
    8020487e:	c1e50513          	addi	a0,a0,-994 # 8020b498 <etext+0x498>
    80204882:	ffffe097          	auipc	ra,0xffffe
    80204886:	282080e7          	jalr	642(ra) # 80202b04 <panic>
}
    8020488a:	0001                	nop
    8020488c:	60e2                	ld	ra,24(sp)
    8020488e:	6442                	ld	s0,16(sp)
    80204890:	6105                	addi	sp,sp,32
    80204892:	8082                	ret

0000000080204894 <semaphore_tryAcquire>:
 *
 * @param sem
 * @return 0 - not get, 1 - get
 */
bool
semaphore_tryAcquire(semaphore_t* sem) {
    80204894:	7179                	addi	sp,sp,-48
    80204896:	f406                	sd	ra,40(sp)
    80204898:	f022                	sd	s0,32(sp)
    8020489a:	1800                	addi	s0,sp,48
    8020489c:	fca43c23          	sd	a0,-40(s0)
    bool ret = 0;
    802048a0:	fe042623          	sw	zero,-20(s0)
    intr_off();
    802048a4:	fffff097          	auipc	ra,0xfffff
    802048a8:	450080e7          	jalr	1104(ra) # 80203cf4 <intr_off>
    if (sem->value > 0) {
    802048ac:	fd843783          	ld	a5,-40(s0)
    802048b0:	439c                	lw	a5,0(a5)
    802048b2:	00f05e63          	blez	a5,802048ce <semaphore_tryAcquire+0x3a>
        --sem->value;
    802048b6:	fd843783          	ld	a5,-40(s0)
    802048ba:	439c                	lw	a5,0(a5)
    802048bc:	37fd                	addiw	a5,a5,-1
    802048be:	0007871b          	sext.w	a4,a5
    802048c2:	fd843783          	ld	a5,-40(s0)
    802048c6:	c398                	sw	a4,0(a5)
        ret = 1;
    802048c8:	4785                	li	a5,1
    802048ca:	fef42623          	sw	a5,-20(s0)
    }
    intr_on();
    802048ce:	fffff097          	auipc	ra,0xfffff
    802048d2:	44e080e7          	jalr	1102(ra) # 80203d1c <intr_on>
    return ret;
    802048d6:	fec42783          	lw	a5,-20(s0)
    802048da:	853e                	mv	a0,a5
    802048dc:	70a2                	ld	ra,40(sp)
    802048de:	7402                	ld	s0,32(sp)
    802048e0:	6145                	addi	sp,sp,48
    802048e2:	8082                	ret

00000000802048e4 <spinlock_isHold>:
#include "dbg.h"

#include "lock/spinlock.h"

int
spinlock_isHold(spinlock_t* lk) {
    802048e4:	7179                	addi	sp,sp,-48
    802048e6:	f406                	sd	ra,40(sp)
    802048e8:	f022                	sd	s0,32(sp)
    802048ea:	ec26                	sd	s1,24(sp)
    802048ec:	1800                	addi	s0,sp,48
    802048ee:	fca43c23          	sd	a0,-40(s0)
    return lk->locked && lk->cpu == getCurrentCPU();
    802048f2:	fd843783          	ld	a5,-40(s0)
    802048f6:	0007c783          	lbu	a5,0(a5)
    802048fa:	cf89                	beqz	a5,80204914 <spinlock_isHold+0x30>
    802048fc:	fd843783          	ld	a5,-40(s0)
    80204900:	6b84                	ld	s1,16(a5)
    80204902:	ffffe097          	auipc	ra,0xffffe
    80204906:	92c080e7          	jalr	-1748(ra) # 8020222e <getCurrentCPU>
    8020490a:	87aa                	mv	a5,a0
    8020490c:	00f49463          	bne	s1,a5,80204914 <spinlock_isHold+0x30>
    80204910:	4785                	li	a5,1
    80204912:	a011                	j	80204916 <spinlock_isHold+0x32>
    80204914:	4781                	li	a5,0
}
    80204916:	853e                	mv	a0,a5
    80204918:	70a2                	ld	ra,40(sp)
    8020491a:	7402                	ld	s0,32(sp)
    8020491c:	64e2                	ld	s1,24(sp)
    8020491e:	6145                	addi	sp,sp,48
    80204920:	8082                	ret

0000000080204922 <spinlock_init>:

void
spinlock_init(spinlock_t* lk, char* name) {
    80204922:	1101                	addi	sp,sp,-32
    80204924:	ec22                	sd	s0,24(sp)
    80204926:	1000                	addi	s0,sp,32
    80204928:	fea43423          	sd	a0,-24(s0)
    8020492c:	feb43023          	sd	a1,-32(s0)
    lk->locked = 0;
    80204930:	fe843783          	ld	a5,-24(s0)
    80204934:	00078023          	sb	zero,0(a5)
    lk->name = name;
    80204938:	fe843783          	ld	a5,-24(s0)
    8020493c:	fe043703          	ld	a4,-32(s0)
    80204940:	e798                	sd	a4,8(a5)
    lk->cpu = NULL;
    80204942:	fe843783          	ld	a5,-24(s0)
    80204946:	0007b823          	sd	zero,16(a5)
}
    8020494a:	0001                	nop
    8020494c:	6462                	ld	s0,24(sp)
    8020494e:	6105                	addi	sp,sp,32
    80204950:	8082                	ret

0000000080204952 <spinlock_acquire>:

void
spinlock_acquire(spinlock_t* lk) {
    80204952:	1101                	addi	sp,sp,-32
    80204954:	ec06                	sd	ra,24(sp)
    80204956:	e822                	sd	s0,16(sp)
    80204958:	1000                	addi	s0,sp,32
    8020495a:	fea43423          	sd	a0,-24(s0)
    intr_push();
    8020495e:	fffff097          	auipc	ra,0xfffff
    80204962:	492080e7          	jalr	1170(ra) # 80203df0 <intr_push>
    if (spinlock_isHold(lk)) {
    80204966:	fe843503          	ld	a0,-24(s0)
    8020496a:	00000097          	auipc	ra,0x0
    8020496e:	f7a080e7          	jalr	-134(ra) # 802048e4 <spinlock_isHold>
    80204972:	87aa                	mv	a5,a0
    80204974:	cb91                	beqz	a5,80204988 <spinlock_acquire+0x36>
        // TODO panic("already hold the key");
        __DEBUG_INFO(already hold the key);
    80204976:	00007517          	auipc	a0,0x7
    8020497a:	b5a50513          	addi	a0,a0,-1190 # 8020b4d0 <etext+0x4d0>
    8020497e:	ffffe097          	auipc	ra,0xffffe
    80204982:	f74080e7          	jalr	-140(ra) # 802028f2 <printf>
        return;
    80204986:	a82d                	j	802049c0 <spinlock_acquire+0x6e>
    }
    while (__sync_lock_test_and_set(&lk->locked, 1))
    80204988:	0001                	nop
    8020498a:	fe843783          	ld	a5,-24(s0)
    8020498e:	ffc7f713          	andi	a4,a5,-4
    80204992:	8b8d                	andi	a5,a5,3
    80204994:	4685                	li	a3,1
    80204996:	0037979b          	slliw	a5,a5,0x3
    8020499a:	00f6963b          	sllw	a2,a3,a5
    8020499e:	44c726af          	amoor.w.aq	a3,a2,(a4)
    802049a2:	00f6d7bb          	srlw	a5,a3,a5
    802049a6:	0ff7f793          	zext.b	a5,a5
    802049aa:	f3e5                	bnez	a5,8020498a <spinlock_acquire+0x38>
        ;

    __sync_synchronize();
    802049ac:	0ff0000f          	fence
    lk->cpu = getCurrentCPU();
    802049b0:	ffffe097          	auipc	ra,0xffffe
    802049b4:	87e080e7          	jalr	-1922(ra) # 8020222e <getCurrentCPU>
    802049b8:	872a                	mv	a4,a0
    802049ba:	fe843783          	ld	a5,-24(s0)
    802049be:	eb98                	sd	a4,16(a5)
}
    802049c0:	60e2                	ld	ra,24(sp)
    802049c2:	6442                	ld	s0,16(sp)
    802049c4:	6105                	addi	sp,sp,32
    802049c6:	8082                	ret

00000000802049c8 <spinlock_release>:

void
spinlock_release(spinlock_t* lk) {
    802049c8:	1101                	addi	sp,sp,-32
    802049ca:	ec06                	sd	ra,24(sp)
    802049cc:	e822                	sd	s0,16(sp)
    802049ce:	1000                	addi	s0,sp,32
    802049d0:	fea43423          	sd	a0,-24(s0)
    if (!spinlock_isHold(lk)) {
    802049d4:	fe843503          	ld	a0,-24(s0)
    802049d8:	00000097          	auipc	ra,0x0
    802049dc:	f0c080e7          	jalr	-244(ra) # 802048e4 <spinlock_isHold>
    802049e0:	87aa                	mv	a5,a0
    802049e2:	eb91                	bnez	a5,802049f6 <spinlock_release+0x2e>
        //    panic("do not hold the key");
        __DEBUG_INFO(do not hold the key);
    802049e4:	00007517          	auipc	a0,0x7
    802049e8:	b0450513          	addi	a0,a0,-1276 # 8020b4e8 <etext+0x4e8>
    802049ec:	ffffe097          	auipc	ra,0xffffe
    802049f0:	f06080e7          	jalr	-250(ra) # 802028f2 <printf>
        return;
    802049f4:	a829                	j	80204a0e <spinlock_release+0x46>
    }
    __sync_synchronize();
    802049f6:	0ff0000f          	fence

    __sync_lock_release(&lk->locked);
    802049fa:	fe843783          	ld	a5,-24(s0)
    802049fe:	0ff0000f          	fence
    80204a02:	00078023          	sb	zero,0(a5)
    intr_pop();
    80204a06:	fffff097          	auipc	ra,0xfffff
    80204a0a:	368080e7          	jalr	872(ra) # 80203d6e <intr_pop>
}
    80204a0e:	60e2                	ld	ra,24(sp)
    80204a10:	6442                	ld	s0,16(sp)
    80204a12:	6105                	addi	sp,sp,32
    80204a14:	8082                	ret

0000000080204a16 <wait_init>:
#include "lock/wait.h"



void
wait_init(wait_t* wait, proc_t* proc) {
    80204a16:	7179                	addi	sp,sp,-48
    80204a18:	f422                	sd	s0,40(sp)
    80204a1a:	1800                	addi	s0,sp,48
    80204a1c:	fca43c23          	sd	a0,-40(s0)
    80204a20:	fcb43823          	sd	a1,-48(s0)
    wait->proc = proc;
    80204a24:	fd843783          	ld	a5,-40(s0)
    80204a28:	fd043703          	ld	a4,-48(s0)
    80204a2c:	e398                	sd	a4,0(a5)
    wait->wakeupFlags = WT_INTERRUPTED;
    80204a2e:	fd843783          	ld	a5,-40(s0)
    80204a32:	80000737          	lui	a4,0x80000
    80204a36:	c798                	sw	a4,8(a5)
    list_init(&(wait->waitLink));
    80204a38:	fd843783          	ld	a5,-40(s0)
    80204a3c:	07e1                	addi	a5,a5,24
    80204a3e:	fef43423          	sd	a5,-24(s0)
    next->prev = prev;
}

__attribute__((always_inline)) static inline void
list_init(list_entry_t* elm) {
    elm->prev = elm->next = elm;
    80204a42:	fe843783          	ld	a5,-24(s0)
    80204a46:	fe843703          	ld	a4,-24(s0)
    80204a4a:	e798                	sd	a4,8(a5)
    80204a4c:	fe843783          	ld	a5,-24(s0)
    80204a50:	6798                	ld	a4,8(a5)
    80204a52:	fe843783          	ld	a5,-24(s0)
    80204a56:	e398                	sd	a4,0(a5)
}
    80204a58:	0001                	nop
}
    80204a5a:	0001                	nop
    80204a5c:	7422                	ld	s0,40(sp)
    80204a5e:	6145                	addi	sp,sp,48
    80204a60:	8082                	ret

0000000080204a62 <waitQueue_init>:

void
waitQueue_init(waitQueue_t* q) {
    80204a62:	7179                	addi	sp,sp,-48
    80204a64:	f422                	sd	s0,40(sp)
    80204a66:	1800                	addi	s0,sp,48
    80204a68:	fca43c23          	sd	a0,-40(s0)
    list_init(&(q->wait_head));
    80204a6c:	fd843783          	ld	a5,-40(s0)
    80204a70:	fef43423          	sd	a5,-24(s0)
    elm->prev = elm->next = elm;
    80204a74:	fe843783          	ld	a5,-24(s0)
    80204a78:	fe843703          	ld	a4,-24(s0)
    80204a7c:	e798                	sd	a4,8(a5)
    80204a7e:	fe843783          	ld	a5,-24(s0)
    80204a82:	6798                	ld	a4,8(a5)
    80204a84:	fe843783          	ld	a5,-24(s0)
    80204a88:	e398                	sd	a4,0(a5)
}
    80204a8a:	0001                	nop
}
    80204a8c:	0001                	nop
    80204a8e:	7422                	ld	s0,40(sp)
    80204a90:	6145                	addi	sp,sp,48
    80204a92:	8082                	ret

0000000080204a94 <waitQueue_add>:

void
waitQueue_add(waitQueue_t* q, wait_t* wait) {
    80204a94:	715d                	addi	sp,sp,-80
    80204a96:	e486                	sd	ra,72(sp)
    80204a98:	e0a2                	sd	s0,64(sp)
    80204a9a:	0880                	addi	s0,sp,80
    80204a9c:	faa43c23          	sd	a0,-72(s0)
    80204aa0:	fab43823          	sd	a1,-80(s0)
    assert(list_empty(&(wait->waitLink)) && wait->proc != NULL);
    80204aa4:	fb043783          	ld	a5,-80(s0)
    80204aa8:	07e1                	addi	a5,a5,24
    80204aaa:	fef43423          	sd	a5,-24(s0)
    list_init(listelm);
}

__attribute__((always_inline)) static inline bool
list_empty(list_entry_t* list) {
    return list->next == list;
    80204aae:	fe843783          	ld	a5,-24(s0)
    80204ab2:	679c                	ld	a5,8(a5)
    80204ab4:	fe843703          	ld	a4,-24(s0)
    80204ab8:	40f707b3          	sub	a5,a4,a5
    80204abc:	0017b793          	seqz	a5,a5
    80204ac0:	0ff7f793          	zext.b	a5,a5
    80204ac4:	2781                	sext.w	a5,a5
    80204ac6:	c789                	beqz	a5,80204ad0 <waitQueue_add+0x3c>
    80204ac8:	fb043783          	ld	a5,-80(s0)
    80204acc:	639c                	ld	a5,0(a5)
    80204ace:	eb89                	bnez	a5,80204ae0 <waitQueue_add+0x4c>
    80204ad0:	00007517          	auipc	a0,0x7
    80204ad4:	a3050513          	addi	a0,a0,-1488 # 8020b500 <etext+0x500>
    80204ad8:	ffffe097          	auipc	ra,0xffffe
    80204adc:	02c080e7          	jalr	44(ra) # 80202b04 <panic>
    wait->waitQueue = q;
    80204ae0:	fb043783          	ld	a5,-80(s0)
    80204ae4:	fb843703          	ld	a4,-72(s0)
    80204ae8:	eb98                	sd	a4,16(a5)
    list_add_before(&(q->wait_head), &(wait->waitLink));
    80204aea:	fb843703          	ld	a4,-72(s0)
    80204aee:	fb043783          	ld	a5,-80(s0)
    80204af2:	07e1                	addi	a5,a5,24
    80204af4:	fee43023          	sd	a4,-32(s0)
    80204af8:	fcf43c23          	sd	a5,-40(s0)
    __list_add(elm, listelm->prev, listelm);
    80204afc:	fe043783          	ld	a5,-32(s0)
    80204b00:	639c                	ld	a5,0(a5)
    80204b02:	fd843703          	ld	a4,-40(s0)
    80204b06:	fce43823          	sd	a4,-48(s0)
    80204b0a:	fcf43423          	sd	a5,-56(s0)
    80204b0e:	fe043783          	ld	a5,-32(s0)
    80204b12:	fcf43023          	sd	a5,-64(s0)
    prev->next = next->prev = elm;
    80204b16:	fc043783          	ld	a5,-64(s0)
    80204b1a:	fd043703          	ld	a4,-48(s0)
    80204b1e:	e398                	sd	a4,0(a5)
    80204b20:	fc043783          	ld	a5,-64(s0)
    80204b24:	6398                	ld	a4,0(a5)
    80204b26:	fc843783          	ld	a5,-56(s0)
    80204b2a:	e798                	sd	a4,8(a5)
    elm->next = next;
    80204b2c:	fd043783          	ld	a5,-48(s0)
    80204b30:	fc043703          	ld	a4,-64(s0)
    80204b34:	e798                	sd	a4,8(a5)
    elm->prev = prev;
    80204b36:	fd043783          	ld	a5,-48(s0)
    80204b3a:	fc843703          	ld	a4,-56(s0)
    80204b3e:	e398                	sd	a4,0(a5)
}
    80204b40:	0001                	nop
}
    80204b42:	0001                	nop
}
    80204b44:	0001                	nop
    80204b46:	60a6                	ld	ra,72(sp)
    80204b48:	6406                	ld	s0,64(sp)
    80204b4a:	6161                	addi	sp,sp,80
    80204b4c:	8082                	ret

0000000080204b4e <waitQueue_del>:

void
waitQueue_del(waitQueue_t* q, wait_t* wait) {
    80204b4e:	715d                	addi	sp,sp,-80
    80204b50:	e486                	sd	ra,72(sp)
    80204b52:	e0a2                	sd	s0,64(sp)
    80204b54:	0880                	addi	s0,sp,80
    80204b56:	faa43c23          	sd	a0,-72(s0)
    80204b5a:	fab43823          	sd	a1,-80(s0)
    assert(!list_empty(&(wait->waitLink)) && wait->waitQueue == q);
    80204b5e:	fb043783          	ld	a5,-80(s0)
    80204b62:	07e1                	addi	a5,a5,24
    80204b64:	fef43423          	sd	a5,-24(s0)
    return list->next == list;
    80204b68:	fe843783          	ld	a5,-24(s0)
    80204b6c:	679c                	ld	a5,8(a5)
    80204b6e:	fe843703          	ld	a4,-24(s0)
    80204b72:	40f707b3          	sub	a5,a4,a5
    80204b76:	0017b793          	seqz	a5,a5
    80204b7a:	0ff7f793          	zext.b	a5,a5
    80204b7e:	2781                	sext.w	a5,a5
    80204b80:	eb81                	bnez	a5,80204b90 <waitQueue_del+0x42>
    80204b82:	fb043783          	ld	a5,-80(s0)
    80204b86:	6b9c                	ld	a5,16(a5)
    80204b88:	fb843703          	ld	a4,-72(s0)
    80204b8c:	00f70a63          	beq	a4,a5,80204ba0 <waitQueue_del+0x52>
    80204b90:	00007517          	auipc	a0,0x7
    80204b94:	9b850513          	addi	a0,a0,-1608 # 8020b548 <etext+0x548>
    80204b98:	ffffe097          	auipc	ra,0xffffe
    80204b9c:	f6c080e7          	jalr	-148(ra) # 80202b04 <panic>
    list_delInit(&(wait->waitLink));
    80204ba0:	fb043783          	ld	a5,-80(s0)
    80204ba4:	07e1                	addi	a5,a5,24
    80204ba6:	fef43023          	sd	a5,-32(s0)
    80204baa:	fe043783          	ld	a5,-32(s0)
    80204bae:	fcf43c23          	sd	a5,-40(s0)
    __list_del(listelm->prev, listelm->next);
    80204bb2:	fd843783          	ld	a5,-40(s0)
    80204bb6:	6398                	ld	a4,0(a5)
    80204bb8:	fd843783          	ld	a5,-40(s0)
    80204bbc:	679c                	ld	a5,8(a5)
    80204bbe:	fce43823          	sd	a4,-48(s0)
    80204bc2:	fcf43423          	sd	a5,-56(s0)
    prev->next = next;
    80204bc6:	fd043783          	ld	a5,-48(s0)
    80204bca:	fc843703          	ld	a4,-56(s0)
    80204bce:	e798                	sd	a4,8(a5)
    next->prev = prev;
    80204bd0:	fc843783          	ld	a5,-56(s0)
    80204bd4:	fd043703          	ld	a4,-48(s0)
    80204bd8:	e398                	sd	a4,0(a5)
}
    80204bda:	0001                	nop
}
    80204bdc:	0001                	nop
    80204bde:	fe043783          	ld	a5,-32(s0)
    80204be2:	fcf43023          	sd	a5,-64(s0)
    elm->prev = elm->next = elm;
    80204be6:	fc043783          	ld	a5,-64(s0)
    80204bea:	fc043703          	ld	a4,-64(s0)
    80204bee:	e798                	sd	a4,8(a5)
    80204bf0:	fc043783          	ld	a5,-64(s0)
    80204bf4:	6798                	ld	a4,8(a5)
    80204bf6:	fc043783          	ld	a5,-64(s0)
    80204bfa:	e398                	sd	a4,0(a5)
}
    80204bfc:	0001                	nop
}
    80204bfe:	0001                	nop
}
    80204c00:	0001                	nop
    80204c02:	60a6                	ld	ra,72(sp)
    80204c04:	6406                	ld	s0,64(sp)
    80204c06:	6161                	addi	sp,sp,80
    80204c08:	8082                	ret

0000000080204c0a <waitQueue_next>:

wait_t*
waitQueue_next(waitQueue_t* q, wait_t* wait) {
    80204c0a:	7139                	addi	sp,sp,-64
    80204c0c:	fc06                	sd	ra,56(sp)
    80204c0e:	f822                	sd	s0,48(sp)
    80204c10:	0080                	addi	s0,sp,64
    80204c12:	fca43423          	sd	a0,-56(s0)
    80204c16:	fcb43023          	sd	a1,-64(s0)
    assert(!list_empty(&(wait->waitLink)) && wait->waitQueue == q);
    80204c1a:	fc043783          	ld	a5,-64(s0)
    80204c1e:	07e1                	addi	a5,a5,24
    80204c20:	fef43023          	sd	a5,-32(s0)
    return list->next == list;
    80204c24:	fe043783          	ld	a5,-32(s0)
    80204c28:	679c                	ld	a5,8(a5)
    80204c2a:	fe043703          	ld	a4,-32(s0)
    80204c2e:	40f707b3          	sub	a5,a4,a5
    80204c32:	0017b793          	seqz	a5,a5
    80204c36:	0ff7f793          	zext.b	a5,a5
    80204c3a:	2781                	sext.w	a5,a5
    80204c3c:	eb81                	bnez	a5,80204c4c <waitQueue_next+0x42>
    80204c3e:	fc043783          	ld	a5,-64(s0)
    80204c42:	6b9c                	ld	a5,16(a5)
    80204c44:	fc843703          	ld	a4,-56(s0)
    80204c48:	00f70a63          	beq	a4,a5,80204c5c <waitQueue_next+0x52>
    80204c4c:	00007517          	auipc	a0,0x7
    80204c50:	8fc50513          	addi	a0,a0,-1796 # 8020b548 <etext+0x548>
    80204c54:	ffffe097          	auipc	ra,0xffffe
    80204c58:	eb0080e7          	jalr	-336(ra) # 80202b04 <panic>
    list_entry_t* le = list_next(&(wait->waitLink));
    80204c5c:	fc043783          	ld	a5,-64(s0)
    80204c60:	07e1                	addi	a5,a5,24
    80204c62:	fcf43c23          	sd	a5,-40(s0)
    return list->prev;
}

__attribute__((always_inline)) static inline list_entry_t*
list_next(list_entry_t* list) {
    return list->next;
    80204c66:	fd843783          	ld	a5,-40(s0)
    80204c6a:	679c                	ld	a5,8(a5)
    80204c6c:	fef43423          	sd	a5,-24(s0)
    if (le != &(q->wait_head))
    80204c70:	fc843783          	ld	a5,-56(s0)
    80204c74:	fe843703          	ld	a4,-24(s0)
    80204c78:	00f70663          	beq	a4,a5,80204c84 <waitQueue_next+0x7a>
        return le2wait(le, waitLink);
    80204c7c:	fe843783          	ld	a5,-24(s0)
    80204c80:	17a1                	addi	a5,a5,-24
    80204c82:	a011                	j	80204c86 <waitQueue_next+0x7c>
    return NULL;
    80204c84:	4781                	li	a5,0
}
    80204c86:	853e                	mv	a0,a5
    80204c88:	70e2                	ld	ra,56(sp)
    80204c8a:	7442                	ld	s0,48(sp)
    80204c8c:	6121                	addi	sp,sp,64
    80204c8e:	8082                	ret

0000000080204c90 <waitQueue_prev>:

wait_t*
waitQueue_prev(waitQueue_t* q, wait_t* wait) {
    80204c90:	7139                	addi	sp,sp,-64
    80204c92:	fc06                	sd	ra,56(sp)
    80204c94:	f822                	sd	s0,48(sp)
    80204c96:	0080                	addi	s0,sp,64
    80204c98:	fca43423          	sd	a0,-56(s0)
    80204c9c:	fcb43023          	sd	a1,-64(s0)
    assert(!list_empty(&(wait->waitLink)) && wait->waitQueue == q);
    80204ca0:	fc043783          	ld	a5,-64(s0)
    80204ca4:	07e1                	addi	a5,a5,24
    80204ca6:	fef43023          	sd	a5,-32(s0)
    return list->next == list;
    80204caa:	fe043783          	ld	a5,-32(s0)
    80204cae:	679c                	ld	a5,8(a5)
    80204cb0:	fe043703          	ld	a4,-32(s0)
    80204cb4:	40f707b3          	sub	a5,a4,a5
    80204cb8:	0017b793          	seqz	a5,a5
    80204cbc:	0ff7f793          	zext.b	a5,a5
    80204cc0:	2781                	sext.w	a5,a5
    80204cc2:	eb81                	bnez	a5,80204cd2 <waitQueue_prev+0x42>
    80204cc4:	fc043783          	ld	a5,-64(s0)
    80204cc8:	6b9c                	ld	a5,16(a5)
    80204cca:	fc843703          	ld	a4,-56(s0)
    80204cce:	00f70a63          	beq	a4,a5,80204ce2 <waitQueue_prev+0x52>
    80204cd2:	00007517          	auipc	a0,0x7
    80204cd6:	87650513          	addi	a0,a0,-1930 # 8020b548 <etext+0x548>
    80204cda:	ffffe097          	auipc	ra,0xffffe
    80204cde:	e2a080e7          	jalr	-470(ra) # 80202b04 <panic>
    list_entry_t* le = list_prev(&(wait->waitLink));
    80204ce2:	fc043783          	ld	a5,-64(s0)
    80204ce6:	07e1                	addi	a5,a5,24
    80204ce8:	fcf43c23          	sd	a5,-40(s0)
    return list->prev;
    80204cec:	fd843783          	ld	a5,-40(s0)
    80204cf0:	639c                	ld	a5,0(a5)
    80204cf2:	fef43423          	sd	a5,-24(s0)
    if (le != &(q->wait_head))
    80204cf6:	fc843783          	ld	a5,-56(s0)
    80204cfa:	fe843703          	ld	a4,-24(s0)
    80204cfe:	00f70663          	beq	a4,a5,80204d0a <waitQueue_prev+0x7a>
        return le2wait(le, waitLink);
    80204d02:	fe843783          	ld	a5,-24(s0)
    80204d06:	17a1                	addi	a5,a5,-24
    80204d08:	a011                	j	80204d0c <waitQueue_prev+0x7c>
    return NULL;
    80204d0a:	4781                	li	a5,0
}
    80204d0c:	853e                	mv	a0,a5
    80204d0e:	70e2                	ld	ra,56(sp)
    80204d10:	7442                	ld	s0,48(sp)
    80204d12:	6121                	addi	sp,sp,64
    80204d14:	8082                	ret

0000000080204d16 <waitQueue_first>:

wait_t*
waitQueue_first(waitQueue_t* q) {
    80204d16:	7179                	addi	sp,sp,-48
    80204d18:	f422                	sd	s0,40(sp)
    80204d1a:	1800                	addi	s0,sp,48
    80204d1c:	fca43c23          	sd	a0,-40(s0)
    list_entry_t* le = list_next(&(q->wait_head));
    80204d20:	fd843783          	ld	a5,-40(s0)
    80204d24:	fef43023          	sd	a5,-32(s0)
    return list->next;
    80204d28:	fe043783          	ld	a5,-32(s0)
    80204d2c:	679c                	ld	a5,8(a5)
    80204d2e:	fef43423          	sd	a5,-24(s0)
    if (le != &(q->wait_head))
    80204d32:	fd843783          	ld	a5,-40(s0)
    80204d36:	fe843703          	ld	a4,-24(s0)
    80204d3a:	00f70663          	beq	a4,a5,80204d46 <waitQueue_first+0x30>
        return le2wait(le, waitLink);
    80204d3e:	fe843783          	ld	a5,-24(s0)
    80204d42:	17a1                	addi	a5,a5,-24
    80204d44:	a011                	j	80204d48 <waitQueue_first+0x32>
    return NULL;
    80204d46:	4781                	li	a5,0
}
    80204d48:	853e                	mv	a0,a5
    80204d4a:	7422                	ld	s0,40(sp)
    80204d4c:	6145                	addi	sp,sp,48
    80204d4e:	8082                	ret

0000000080204d50 <waitQueue_last>:

wait_t*
waitQueue_last(waitQueue_t* q) {
    80204d50:	7179                	addi	sp,sp,-48
    80204d52:	f422                	sd	s0,40(sp)
    80204d54:	1800                	addi	s0,sp,48
    80204d56:	fca43c23          	sd	a0,-40(s0)
    list_entry_t* le = list_prev(&(q->wait_head));
    80204d5a:	fd843783          	ld	a5,-40(s0)
    80204d5e:	fef43023          	sd	a5,-32(s0)
    return list->prev;
    80204d62:	fe043783          	ld	a5,-32(s0)
    80204d66:	639c                	ld	a5,0(a5)
    80204d68:	fef43423          	sd	a5,-24(s0)
    if (le != &(q->wait_head))
    80204d6c:	fd843783          	ld	a5,-40(s0)
    80204d70:	fe843703          	ld	a4,-24(s0)
    80204d74:	00f70663          	beq	a4,a5,80204d80 <waitQueue_last+0x30>
        return le2wait(le, waitLink);
    80204d78:	fe843783          	ld	a5,-24(s0)
    80204d7c:	17a1                	addi	a5,a5,-24
    80204d7e:	a011                	j	80204d82 <waitQueue_last+0x32>
    return NULL;
    80204d80:	4781                	li	a5,0
}
    80204d82:	853e                	mv	a0,a5
    80204d84:	7422                	ld	s0,40(sp)
    80204d86:	6145                	addi	sp,sp,48
    80204d88:	8082                	ret

0000000080204d8a <waitQueue_isEmpty>:

bool
waitQueue_isEmpty(waitQueue_t* q) {
    80204d8a:	7179                	addi	sp,sp,-48
    80204d8c:	f422                	sd	s0,40(sp)
    80204d8e:	1800                	addi	s0,sp,48
    80204d90:	fca43c23          	sd	a0,-40(s0)
    return list_empty(&(q->wait_head));
    80204d94:	fd843783          	ld	a5,-40(s0)
    80204d98:	fef43423          	sd	a5,-24(s0)
    return list->next == list;
    80204d9c:	fe843783          	ld	a5,-24(s0)
    80204da0:	679c                	ld	a5,8(a5)
    80204da2:	fe843703          	ld	a4,-24(s0)
    80204da6:	40f707b3          	sub	a5,a4,a5
    80204daa:	0017b793          	seqz	a5,a5
    80204dae:	0ff7f793          	zext.b	a5,a5
    80204db2:	2781                	sext.w	a5,a5
}
    80204db4:	853e                	mv	a0,a5
    80204db6:	7422                	ld	s0,40(sp)
    80204db8:	6145                	addi	sp,sp,48
    80204dba:	8082                	ret

0000000080204dbc <wait_isInQueue>:

bool
wait_isInQueue(wait_t* wait) {
    80204dbc:	7179                	addi	sp,sp,-48
    80204dbe:	f422                	sd	s0,40(sp)
    80204dc0:	1800                	addi	s0,sp,48
    80204dc2:	fca43c23          	sd	a0,-40(s0)
    return !list_empty(&(wait->waitLink));
    80204dc6:	fd843783          	ld	a5,-40(s0)
    80204dca:	07e1                	addi	a5,a5,24
    80204dcc:	fef43423          	sd	a5,-24(s0)
    80204dd0:	fe843783          	ld	a5,-24(s0)
    80204dd4:	679c                	ld	a5,8(a5)
    80204dd6:	fe843703          	ld	a4,-24(s0)
    80204dda:	40f707b3          	sub	a5,a4,a5
    80204dde:	0017b793          	seqz	a5,a5
    80204de2:	0ff7f793          	zext.b	a5,a5
    80204de6:	2781                	sext.w	a5,a5
    80204de8:	0017b793          	seqz	a5,a5
    80204dec:	0ff7f793          	zext.b	a5,a5
    80204df0:	2781                	sext.w	a5,a5
}
    80204df2:	853e                	mv	a0,a5
    80204df4:	7422                	ld	s0,40(sp)
    80204df6:	6145                	addi	sp,sp,48
    80204df8:	8082                	ret

0000000080204dfa <wakeup_wait>:

void
wakeup_wait(waitQueue_t* q, wait_t* wait, uint32_t wakeupFlags, bool del) {
    80204dfa:	7179                	addi	sp,sp,-48
    80204dfc:	f406                	sd	ra,40(sp)
    80204dfe:	f022                	sd	s0,32(sp)
    80204e00:	1800                	addi	s0,sp,48
    80204e02:	fea43423          	sd	a0,-24(s0)
    80204e06:	feb43023          	sd	a1,-32(s0)
    80204e0a:	87b2                	mv	a5,a2
    80204e0c:	8736                	mv	a4,a3
    80204e0e:	fcf42e23          	sw	a5,-36(s0)
    80204e12:	87ba                	mv	a5,a4
    80204e14:	fcf42c23          	sw	a5,-40(s0)
    if (del)
    80204e18:	fd842783          	lw	a5,-40(s0)
    80204e1c:	2781                	sext.w	a5,a5
    80204e1e:	cb89                	beqz	a5,80204e30 <wakeup_wait+0x36>
        waitQueue_del(q, wait);
    80204e20:	fe043583          	ld	a1,-32(s0)
    80204e24:	fe843503          	ld	a0,-24(s0)
    80204e28:	00000097          	auipc	ra,0x0
    80204e2c:	d26080e7          	jalr	-730(ra) # 80204b4e <waitQueue_del>
    wait->wakeupFlags = wakeupFlags;
    80204e30:	fe043783          	ld	a5,-32(s0)
    80204e34:	fdc42703          	lw	a4,-36(s0)
    80204e38:	c798                	sw	a4,8(a5)
    // proc_wakeup(wait->proc);
}
    80204e3a:	0001                	nop
    80204e3c:	70a2                	ld	ra,40(sp)
    80204e3e:	7402                	ld	s0,32(sp)
    80204e40:	6145                	addi	sp,sp,48
    80204e42:	8082                	ret

0000000080204e44 <wakeup_first>:

void
wakeup_first(waitQueue_t* q, uint32_t wakeupFlags, bool del) {
    80204e44:	7179                	addi	sp,sp,-48
    80204e46:	f406                	sd	ra,40(sp)
    80204e48:	f022                	sd	s0,32(sp)
    80204e4a:	1800                	addi	s0,sp,48
    80204e4c:	fca43c23          	sd	a0,-40(s0)
    80204e50:	87ae                	mv	a5,a1
    80204e52:	8732                	mv	a4,a2
    80204e54:	fcf42a23          	sw	a5,-44(s0)
    80204e58:	87ba                	mv	a5,a4
    80204e5a:	fcf42823          	sw	a5,-48(s0)
    wait_t* wait = waitQueue_first(q);
    80204e5e:	fd843503          	ld	a0,-40(s0)
    80204e62:	00000097          	auipc	ra,0x0
    80204e66:	eb4080e7          	jalr	-332(ra) # 80204d16 <waitQueue_first>
    80204e6a:	fea43423          	sd	a0,-24(s0)
    if (wait != NULL)
    80204e6e:	fe843783          	ld	a5,-24(s0)
    80204e72:	cf99                	beqz	a5,80204e90 <wakeup_first+0x4c>
        wakeup_wait(q, wait, wakeupFlags, del);
    80204e74:	fd042703          	lw	a4,-48(s0)
    80204e78:	fd442783          	lw	a5,-44(s0)
    80204e7c:	86ba                	mv	a3,a4
    80204e7e:	863e                	mv	a2,a5
    80204e80:	fe843583          	ld	a1,-24(s0)
    80204e84:	fd843503          	ld	a0,-40(s0)
    80204e88:	00000097          	auipc	ra,0x0
    80204e8c:	f72080e7          	jalr	-142(ra) # 80204dfa <wakeup_wait>
}
    80204e90:	0001                	nop
    80204e92:	70a2                	ld	ra,40(sp)
    80204e94:	7402                	ld	s0,32(sp)
    80204e96:	6145                	addi	sp,sp,48
    80204e98:	8082                	ret

0000000080204e9a <wakeup_queue>:

void
wakeup_queue(waitQueue_t* q, uint32_t wakeupFlags, bool del) {
    80204e9a:	7179                	addi	sp,sp,-48
    80204e9c:	f406                	sd	ra,40(sp)
    80204e9e:	f022                	sd	s0,32(sp)
    80204ea0:	1800                	addi	s0,sp,48
    80204ea2:	fca43c23          	sd	a0,-40(s0)
    80204ea6:	87ae                	mv	a5,a1
    80204ea8:	8732                	mv	a4,a2
    80204eaa:	fcf42a23          	sw	a5,-44(s0)
    80204eae:	87ba                	mv	a5,a4
    80204eb0:	fcf42823          	sw	a5,-48(s0)
    wait_t* wait = waitQueue_first(q);
    80204eb4:	fd843503          	ld	a0,-40(s0)
    80204eb8:	00000097          	auipc	ra,0x0
    80204ebc:	e5e080e7          	jalr	-418(ra) # 80204d16 <waitQueue_first>
    80204ec0:	fea43423          	sd	a0,-24(s0)
    if (wait != NULL) {
    80204ec4:	fe843783          	ld	a5,-24(s0)
    80204ec8:	cbb1                	beqz	a5,80204f1c <wakeup_queue+0x82>
        while (wait != NULL) {
    80204eca:	a0b1                	j	80204f16 <wakeup_queue+0x7c>
            wakeup_wait(q, wait, wakeupFlags, del);
    80204ecc:	fd042703          	lw	a4,-48(s0)
    80204ed0:	fd442783          	lw	a5,-44(s0)
    80204ed4:	86ba                	mv	a3,a4
    80204ed6:	863e                	mv	a2,a5
    80204ed8:	fe843583          	ld	a1,-24(s0)
    80204edc:	fd843503          	ld	a0,-40(s0)
    80204ee0:	00000097          	auipc	ra,0x0
    80204ee4:	f1a080e7          	jalr	-230(ra) # 80204dfa <wakeup_wait>
            if (del)
    80204ee8:	fd042783          	lw	a5,-48(s0)
    80204eec:	2781                	sext.w	a5,a5
    80204eee:	cb91                	beqz	a5,80204f02 <wakeup_queue+0x68>
                wait = waitQueue_first(q);
    80204ef0:	fd843503          	ld	a0,-40(s0)
    80204ef4:	00000097          	auipc	ra,0x0
    80204ef8:	e22080e7          	jalr	-478(ra) # 80204d16 <waitQueue_first>
    80204efc:	fea43423          	sd	a0,-24(s0)
    80204f00:	a819                	j	80204f16 <wakeup_queue+0x7c>
            else
                wait = waitQueue_next(q, wait);
    80204f02:	fe843583          	ld	a1,-24(s0)
    80204f06:	fd843503          	ld	a0,-40(s0)
    80204f0a:	00000097          	auipc	ra,0x0
    80204f0e:	d00080e7          	jalr	-768(ra) # 80204c0a <waitQueue_next>
    80204f12:	fea43423          	sd	a0,-24(s0)
        while (wait != NULL) {
    80204f16:	fe843783          	ld	a5,-24(s0)
    80204f1a:	fbcd                	bnez	a5,80204ecc <wakeup_queue+0x32>
        }
    }
}
    80204f1c:	0001                	nop
    80204f1e:	70a2                	ld	ra,40(sp)
    80204f20:	7402                	ld	s0,32(sp)
    80204f22:	6145                	addi	sp,sp,48
    80204f24:	8082                	ret

0000000080204f26 <wait_current_set>:

void
wait_current_set(waitQueue_t* q, wait_t* wait, uint32_t waitState) {
    80204f26:	7179                	addi	sp,sp,-48
    80204f28:	f406                	sd	ra,40(sp)
    80204f2a:	f022                	sd	s0,32(sp)
    80204f2c:	1800                	addi	s0,sp,48
    80204f2e:	fea43423          	sd	a0,-24(s0)
    80204f32:	feb43023          	sd	a1,-32(s0)
    80204f36:	87b2                	mv	a5,a2
    80204f38:	fcf42e23          	sw	a5,-36(s0)
    assert(getCurrentProc() != NULL);
    80204f3c:	ffffd097          	auipc	ra,0xffffd
    80204f40:	c92080e7          	jalr	-878(ra) # 80201bce <getCurrentProc>
    80204f44:	87aa                	mv	a5,a0
    80204f46:	eb89                	bnez	a5,80204f58 <wait_current_set+0x32>
    80204f48:	00006517          	auipc	a0,0x6
    80204f4c:	64850513          	addi	a0,a0,1608 # 8020b590 <etext+0x590>
    80204f50:	ffffe097          	auipc	ra,0xffffe
    80204f54:	bb4080e7          	jalr	-1100(ra) # 80202b04 <panic>
    wait_init(wait, getCurrentProc());
    80204f58:	ffffd097          	auipc	ra,0xffffd
    80204f5c:	c76080e7          	jalr	-906(ra) # 80201bce <getCurrentProc>
    80204f60:	87aa                	mv	a5,a0
    80204f62:	85be                	mv	a1,a5
    80204f64:	fe043503          	ld	a0,-32(s0)
    80204f68:	00000097          	auipc	ra,0x0
    80204f6c:	aae080e7          	jalr	-1362(ra) # 80204a16 <wait_init>
    getCurrentProc()->state = SLEEPING;
    80204f70:	ffffd097          	auipc	ra,0xffffd
    80204f74:	c5e080e7          	jalr	-930(ra) # 80201bce <getCurrentProc>
    80204f78:	872a                	mv	a4,a0
    80204f7a:	4791                	li	a5,4
    80204f7c:	c31c                	sw	a5,0(a4)
    getCurrentProc()->waitState = waitState;
    80204f7e:	ffffd097          	auipc	ra,0xffffd
    80204f82:	c50080e7          	jalr	-944(ra) # 80201bce <getCurrentProc>
    80204f86:	872a                	mv	a4,a0
    80204f88:	fdc42783          	lw	a5,-36(s0)
    80204f8c:	c35c                	sw	a5,4(a4)
    waitQueue_add(q, wait);
    80204f8e:	fe043583          	ld	a1,-32(s0)
    80204f92:	fe843503          	ld	a0,-24(s0)
    80204f96:	00000097          	auipc	ra,0x0
    80204f9a:	afe080e7          	jalr	-1282(ra) # 80204a94 <waitQueue_add>
    80204f9e:	0001                	nop
    80204fa0:	70a2                	ld	ra,40(sp)
    80204fa2:	7402                	ld	s0,32(sp)
    80204fa4:	6145                	addi	sp,sp,48
    80204fa6:	8082                	ret

0000000080204fa8 <firstClusSec>:
} pathCache;

dirent_t root;

static inline uint32_t
firstClusSec(uint32_t clus) {
    80204fa8:	1101                	addi	sp,sp,-32
    80204faa:	ec22                	sd	s0,24(sp)
    80204fac:	1000                	addi	s0,sp,32
    80204fae:	87aa                	mv	a5,a0
    80204fb0:	fef42623          	sw	a5,-20(s0)
    return (clus - 2) * fat32.bpb.secPerCluster + fat32.firstDataSec;
    80204fb4:	fec42783          	lw	a5,-20(s0)
    80204fb8:	37f9                	addiw	a5,a5,-2
    80204fba:	0007871b          	sext.w	a4,a5
    80204fbe:	00022797          	auipc	a5,0x22
    80204fc2:	63278793          	addi	a5,a5,1586 # 802275f0 <fat32>
    80204fc6:	00d7c783          	lbu	a5,13(a5)
    80204fca:	2781                	sext.w	a5,a5
    80204fcc:	02f707bb          	mulw	a5,a4,a5
    80204fd0:	0007871b          	sext.w	a4,a5
    80204fd4:	00022797          	auipc	a5,0x22
    80204fd8:	61c78793          	addi	a5,a5,1564 # 802275f0 <fat32>
    80204fdc:	2007a783          	lw	a5,512(a5)
    80204fe0:	9fb9                	addw	a5,a5,a4
    80204fe2:	2781                	sext.w	a5,a5
}
    80204fe4:	853e                	mv	a0,a5
    80204fe6:	6462                	ld	s0,24(sp)
    80204fe8:	6105                	addi	sp,sp,32
    80204fea:	8082                	ret

0000000080204fec <fatClusSec>:

static inline uint32_t
fatClusSec(uint32_t clus, uint8_t fatNum) {
    80204fec:	1101                	addi	sp,sp,-32
    80204fee:	ec22                	sd	s0,24(sp)
    80204ff0:	1000                	addi	s0,sp,32
    80204ff2:	87aa                	mv	a5,a0
    80204ff4:	872e                	mv	a4,a1
    80204ff6:	fef42623          	sw	a5,-20(s0)
    80204ffa:	87ba                	mv	a5,a4
    80204ffc:	fef405a3          	sb	a5,-21(s0)
    return fat32.firstDataSec + (clus - 2) * fat32.bpb.secPerCluster;
    80205000:	00022797          	auipc	a5,0x22
    80205004:	5f078793          	addi	a5,a5,1520 # 802275f0 <fat32>
    80205008:	2007a703          	lw	a4,512(a5)
    8020500c:	fec42783          	lw	a5,-20(s0)
    80205010:	37f9                	addiw	a5,a5,-2
    80205012:	0007869b          	sext.w	a3,a5
    80205016:	00022797          	auipc	a5,0x22
    8020501a:	5da78793          	addi	a5,a5,1498 # 802275f0 <fat32>
    8020501e:	00d7c783          	lbu	a5,13(a5)
    80205022:	2781                	sext.w	a5,a5
    80205024:	02f687bb          	mulw	a5,a3,a5
    80205028:	2781                	sext.w	a5,a5
    8020502a:	9fb9                	addw	a5,a5,a4
    8020502c:	2781                	sext.w	a5,a5
}
    8020502e:	853e                	mv	a0,a5
    80205030:	6462                	ld	s0,24(sp)
    80205032:	6105                	addi	sp,sp,32
    80205034:	8082                	ret

0000000080205036 <fatTable_read>:
fatClusOff(uint32_t clus) {
    return clus % fat32.bpb.bytesPerSector;
}

static inline uint32_t
fatTable_read(uint32_t clus) {
    80205036:	1101                	addi	sp,sp,-32
    80205038:	ec22                	sd	s0,24(sp)
    8020503a:	1000                	addi	s0,sp,32
    8020503c:	87aa                	mv	a5,a0
    8020503e:	fef42623          	sw	a5,-20(s0)
    if (clus >= FAT32_EOC)
    80205042:	fec42783          	lw	a5,-20(s0)
    80205046:	0007871b          	sext.w	a4,a5
    8020504a:	100007b7          	lui	a5,0x10000
    8020504e:	17dd                	addi	a5,a5,-9 # ffffff7 <_entry-0x70200009>
    80205050:	00e7f563          	bgeu	a5,a4,8020505a <fatTable_read+0x24>
        return clus;
    80205054:	fec42783          	lw	a5,-20(s0)
    80205058:	a80d                	j	8020508a <fatTable_read+0x54>
    if (clus > fat32.dataClusNum)
    8020505a:	00022797          	auipc	a5,0x22
    8020505e:	59678793          	addi	a5,a5,1430 # 802275f0 <fat32>
    80205062:	2087a703          	lw	a4,520(a5)
    80205066:	fec42783          	lw	a5,-20(s0)
    8020506a:	2781                	sext.w	a5,a5
    8020506c:	00f77463          	bgeu	a4,a5,80205074 <fatTable_read+0x3e>
        return 0;
    80205070:	4781                	li	a5,0
    80205072:	a821                	j	8020508a <fatTable_read+0x54>
    // uint32_t fat_sec=
    return fat32.fatTable[clus];
    80205074:	00022717          	auipc	a4,0x22
    80205078:	57c70713          	addi	a4,a4,1404 # 802275f0 <fat32>
    8020507c:	fec46783          	lwu	a5,-20(s0)
    80205080:	08478793          	addi	a5,a5,132
    80205084:	078a                	slli	a5,a5,0x2
    80205086:	97ba                	add	a5,a5,a4
    80205088:	43dc                	lw	a5,4(a5)
}
    8020508a:	853e                	mv	a0,a5
    8020508c:	6462                	ld	s0,24(sp)
    8020508e:	6105                	addi	sp,sp,32
    80205090:	8082                	ret

0000000080205092 <fatTable_write>:

int
fatTable_write(uint32_t clus, uint32_t content) {
    80205092:	7179                	addi	sp,sp,-48
    80205094:	f406                	sd	ra,40(sp)
    80205096:	f022                	sd	s0,32(sp)
    80205098:	1800                	addi	s0,sp,48
    8020509a:	87aa                	mv	a5,a0
    8020509c:	872e                	mv	a4,a1
    8020509e:	fcf42e23          	sw	a5,-36(s0)
    802050a2:	87ba                	mv	a5,a4
    802050a4:	fcf42c23          	sw	a5,-40(s0)
    if (clus > fat32.dataClusNum)
    802050a8:	00022797          	auipc	a5,0x22
    802050ac:	54878793          	addi	a5,a5,1352 # 802275f0 <fat32>
    802050b0:	2087a703          	lw	a4,520(a5)
    802050b4:	fdc42783          	lw	a5,-36(s0)
    802050b8:	2781                	sext.w	a5,a5
    802050ba:	00f77463          	bgeu	a4,a5,802050c2 <fatTable_write+0x30>
        return -1;
    802050be:	57fd                	li	a5,-1
    802050c0:	a0b5                	j	8020512c <fatTable_write+0x9a>
    uint32_t fatSec = fatClusSec(clus, 1);
    802050c2:	fdc42783          	lw	a5,-36(s0)
    802050c6:	4585                	li	a1,1
    802050c8:	853e                	mv	a0,a5
    802050ca:	00000097          	auipc	ra,0x0
    802050ce:	f22080e7          	jalr	-222(ra) # 80204fec <fatClusSec>
    802050d2:	87aa                	mv	a5,a0
    802050d4:	fef42623          	sw	a5,-20(s0)
    fat32.fatTable[clus] = content;  // TODO
    802050d8:	00022717          	auipc	a4,0x22
    802050dc:	51870713          	addi	a4,a4,1304 # 802275f0 <fat32>
    802050e0:	fdc46783          	lwu	a5,-36(s0)
    802050e4:	08478793          	addi	a5,a5,132
    802050e8:	078a                	slli	a5,a5,0x2
    802050ea:	97ba                	add	a5,a5,a4
    802050ec:	fd842703          	lw	a4,-40(s0)
    802050f0:	c3d8                	sw	a4,4(a5)
    disk_write((uint8_t*)(fat32.fatTable + clus / fat32.fatEntryPerSec), fatSec);
    802050f2:	00022797          	auipc	a5,0x22
    802050f6:	4fe78793          	addi	a5,a5,1278 # 802275f0 <fat32>
    802050fa:	2107a783          	lw	a5,528(a5)
    802050fe:	fdc42703          	lw	a4,-36(s0)
    80205102:	02f757bb          	divuw	a5,a4,a5
    80205106:	2781                	sext.w	a5,a5
    80205108:	1782                	slli	a5,a5,0x20
    8020510a:	9381                	srli	a5,a5,0x20
    8020510c:	00279713          	slli	a4,a5,0x2
    80205110:	00022797          	auipc	a5,0x22
    80205114:	6f478793          	addi	a5,a5,1780 # 80227804 <fat32+0x214>
    80205118:	97ba                	add	a5,a5,a4
    8020511a:	fec42703          	lw	a4,-20(s0)
    8020511e:	85ba                	mv	a1,a4
    80205120:	853e                	mv	a0,a5
    80205122:	00003097          	auipc	ra,0x3
    80205126:	822080e7          	jalr	-2014(ra) # 80207944 <disk_write>
    return 0;
    8020512a:	4781                	li	a5,0
}
    8020512c:	853e                	mv	a0,a5
    8020512e:	70a2                	ld	ra,40(sp)
    80205130:	7402                	ld	s0,32(sp)
    80205132:	6145                	addi	sp,sp,48
    80205134:	8082                	ret

0000000080205136 <clus_zero>:

void
clus_zero(uint32_t clus) {
    80205136:	dd010113          	addi	sp,sp,-560
    8020513a:	22113423          	sd	ra,552(sp)
    8020513e:	22813023          	sd	s0,544(sp)
    80205142:	1c00                	addi	s0,sp,560
    80205144:	87aa                	mv	a5,a0
    80205146:	dcf42e23          	sw	a5,-548(s0)
    uint32_t sec = firstClusSec(clus);
    8020514a:	ddc42783          	lw	a5,-548(s0)
    8020514e:	853e                	mv	a0,a5
    80205150:	00000097          	auipc	ra,0x0
    80205154:	e58080e7          	jalr	-424(ra) # 80204fa8 <firstClusSec>
    80205158:	87aa                	mv	a5,a0
    8020515a:	fef42623          	sw	a5,-20(s0)
    byte_t buf[BSIZE] = {0};
    8020515e:	de043423          	sd	zero,-536(s0)
    80205162:	df040793          	addi	a5,s0,-528
    80205166:	1f800713          	li	a4,504
    8020516a:	863a                	mv	a2,a4
    8020516c:	4581                	li	a1,0
    8020516e:	853e                	mv	a0,a5
    80205170:	ffffe097          	auipc	ra,0xffffe
    80205174:	9b6080e7          	jalr	-1610(ra) # 80202b26 <memset>
    for (int i = 0; i < fat32.bpb.secPerCluster; ++i, ++sec)
    80205178:	fe042423          	sw	zero,-24(s0)
    8020517c:	a02d                	j	802051a6 <clus_zero+0x70>
        disk_write(buf, sec);
    8020517e:	fec42703          	lw	a4,-20(s0)
    80205182:	de840793          	addi	a5,s0,-536
    80205186:	85ba                	mv	a1,a4
    80205188:	853e                	mv	a0,a5
    8020518a:	00002097          	auipc	ra,0x2
    8020518e:	7ba080e7          	jalr	1978(ra) # 80207944 <disk_write>
    for (int i = 0; i < fat32.bpb.secPerCluster; ++i, ++sec)
    80205192:	fe842783          	lw	a5,-24(s0)
    80205196:	2785                	addiw	a5,a5,1
    80205198:	fef42423          	sw	a5,-24(s0)
    8020519c:	fec42783          	lw	a5,-20(s0)
    802051a0:	2785                	addiw	a5,a5,1
    802051a2:	fef42623          	sw	a5,-20(s0)
    802051a6:	00022797          	auipc	a5,0x22
    802051aa:	44a78793          	addi	a5,a5,1098 # 802275f0 <fat32>
    802051ae:	00d7c783          	lbu	a5,13(a5)
    802051b2:	0007871b          	sext.w	a4,a5
    802051b6:	fe842783          	lw	a5,-24(s0)
    802051ba:	2781                	sext.w	a5,a5
    802051bc:	fce7c1e3          	blt	a5,a4,8020517e <clus_zero+0x48>
}
    802051c0:	0001                	nop
    802051c2:	0001                	nop
    802051c4:	22813083          	ld	ra,552(sp)
    802051c8:	22013403          	ld	s0,544(sp)
    802051cc:	23010113          	addi	sp,sp,560
    802051d0:	8082                	ret

00000000802051d2 <clus_alloc>:

int
clus_alloc(uint8_t dev) {
    802051d2:	7179                	addi	sp,sp,-48
    802051d4:	f406                	sd	ra,40(sp)
    802051d6:	f022                	sd	s0,32(sp)
    802051d8:	1800                	addi	s0,sp,48
    802051da:	87aa                	mv	a5,a0
    802051dc:	fcf40fa3          	sb	a5,-33(s0)
    for (int i = 0; i < fat32.bpb.secPerFAT32; ++i)
    802051e0:	fe042623          	sw	zero,-20(s0)
    802051e4:	a81d                	j	8020521a <clus_alloc+0x48>
        if (fatTable_read(i) == 0) {  // TODO
    802051e6:	fec42783          	lw	a5,-20(s0)
    802051ea:	853e                	mv	a0,a5
    802051ec:	00000097          	auipc	ra,0x0
    802051f0:	e4a080e7          	jalr	-438(ra) # 80205036 <fatTable_read>
    802051f4:	87aa                	mv	a5,a0
    802051f6:	2781                	sext.w	a5,a5
    802051f8:	ef81                	bnez	a5,80205210 <clus_alloc+0x3e>
            fatTable_write(i, 0xffffffff);
    802051fa:	fec42783          	lw	a5,-20(s0)
    802051fe:	55fd                	li	a1,-1
    80205200:	853e                	mv	a0,a5
    80205202:	00000097          	auipc	ra,0x0
    80205206:	e90080e7          	jalr	-368(ra) # 80205092 <fatTable_write>
            return i;
    8020520a:	fec42783          	lw	a5,-20(s0)
    8020520e:	a005                	j	8020522e <clus_alloc+0x5c>
    for (int i = 0; i < fat32.bpb.secPerFAT32; ++i)
    80205210:	fec42783          	lw	a5,-20(s0)
    80205214:	2785                	addiw	a5,a5,1
    80205216:	fef42623          	sw	a5,-20(s0)
    8020521a:	00022797          	auipc	a5,0x22
    8020521e:	3d678793          	addi	a5,a5,982 # 802275f0 <fat32>
    80205222:	53d8                	lw	a4,36(a5)
    80205224:	fec42783          	lw	a5,-20(s0)
    80205228:	fae7efe3          	bltu	a5,a4,802051e6 <clus_alloc+0x14>
        }
    return -E_NO_MEM;
    8020522c:	57f1                	li	a5,-4
}
    8020522e:	853e                	mv	a0,a5
    80205230:	70a2                	ld	ra,40(sp)
    80205232:	7402                	ld	s0,32(sp)
    80205234:	6145                	addi	sp,sp,48
    80205236:	8082                	ret

0000000080205238 <clus_free>:

int
clus_free(uint32_t clus) {
    80205238:	1101                	addi	sp,sp,-32
    8020523a:	ec06                	sd	ra,24(sp)
    8020523c:	e822                	sd	s0,16(sp)
    8020523e:	1000                	addi	s0,sp,32
    80205240:	87aa                	mv	a5,a0
    80205242:	fef42623          	sw	a5,-20(s0)
    return fatTable_write(clus, 0);
    80205246:	fec42783          	lw	a5,-20(s0)
    8020524a:	4581                	li	a1,0
    8020524c:	853e                	mv	a0,a5
    8020524e:	00000097          	auipc	ra,0x0
    80205252:	e44080e7          	jalr	-444(ra) # 80205092 <fatTable_write>
    80205256:	87aa                	mv	a5,a0
}
    80205258:	853e                	mv	a0,a5
    8020525a:	60e2                	ld	ra,24(sp)
    8020525c:	6442                	ld	s0,16(sp)
    8020525e:	6105                	addi	sp,sp,32
    80205260:	8082                	ret

0000000080205262 <clus_io>:
 * @param off
 * @param len
 * @return uint32_t
 */
uint32_t
clus_io(uint32_t clus, bool write, int user, byte_t* data, uint32_t off, uint32_t len) {
    80205262:	da010113          	addi	sp,sp,-608
    80205266:	24113c23          	sd	ra,600(sp)
    8020526a:	24813823          	sd	s0,592(sp)
    8020526e:	24913423          	sd	s1,584(sp)
    80205272:	1480                	addi	s0,sp,608
    80205274:	dad43423          	sd	a3,-600(s0)
    80205278:	86ba                	mv	a3,a4
    8020527a:	873e                	mv	a4,a5
    8020527c:	87aa                	mv	a5,a0
    8020527e:	daf42e23          	sw	a5,-580(s0)
    80205282:	87ae                	mv	a5,a1
    80205284:	daf42c23          	sw	a5,-584(s0)
    80205288:	87b2                	mv	a5,a2
    8020528a:	daf42a23          	sw	a5,-588(s0)
    8020528e:	87b6                	mv	a5,a3
    80205290:	daf42823          	sw	a5,-592(s0)
    80205294:	87ba                	mv	a5,a4
    80205296:	daf42223          	sw	a5,-604(s0)
    if (off + len > fat32.bytePerClus)  //?不支持超过一簇的读写
    8020529a:	db042703          	lw	a4,-592(s0)
    8020529e:	da442783          	lw	a5,-604(s0)
    802052a2:	9fb9                	addw	a5,a5,a4
    802052a4:	0007871b          	sext.w	a4,a5
    802052a8:	00022797          	auipc	a5,0x22
    802052ac:	34878793          	addi	a5,a5,840 # 802275f0 <fat32>
    802052b0:	20c7a783          	lw	a5,524(a5)
    802052b4:	00e7fa63          	bgeu	a5,a4,802052c8 <clus_io+0x66>
        panic("offset out of range");
    802052b8:	00006517          	auipc	a0,0x6
    802052bc:	31850513          	addi	a0,a0,792 # 8020b5d0 <illegal+0x10>
    802052c0:	ffffe097          	auipc	ra,0xffffe
    802052c4:	844080e7          	jalr	-1980(ra) # 80202b04 <panic>
    uint32_t sec = fatClusSec(clus, 1) + off / fat32.bpb.bytesPerSector;
    802052c8:	dbc42783          	lw	a5,-580(s0)
    802052cc:	4585                	li	a1,1
    802052ce:	853e                	mv	a0,a5
    802052d0:	00000097          	auipc	ra,0x0
    802052d4:	d1c080e7          	jalr	-740(ra) # 80204fec <fatClusSec>
    802052d8:	87aa                	mv	a5,a0
    802052da:	0007871b          	sext.w	a4,a5
    802052de:	00022797          	auipc	a5,0x22
    802052e2:	31278793          	addi	a5,a5,786 # 802275f0 <fat32>
    802052e6:	679c                	ld	a5,8(a5)
    802052e8:	83e1                	srli	a5,a5,0x18
    802052ea:	9bfd                	andi	a5,a5,-1
    802052ec:	17c2                	slli	a5,a5,0x30
    802052ee:	93c1                	srli	a5,a5,0x30
    802052f0:	2781                	sext.w	a5,a5
    802052f2:	db042683          	lw	a3,-592(s0)
    802052f6:	02f6d7bb          	divuw	a5,a3,a5
    802052fa:	2781                	sext.w	a5,a5
    802052fc:	9fb9                	addw	a5,a5,a4
    802052fe:	fcf42e23          	sw	a5,-36(s0)
    off %= fat32.bpb.bytesPerSector;
    80205302:	00022797          	auipc	a5,0x22
    80205306:	2ee78793          	addi	a5,a5,750 # 802275f0 <fat32>
    8020530a:	679c                	ld	a5,8(a5)
    8020530c:	83e1                	srli	a5,a5,0x18
    8020530e:	9bfd                	andi	a5,a5,-1
    80205310:	17c2                	slli	a5,a5,0x30
    80205312:	93c1                	srli	a5,a5,0x30
    80205314:	2781                	sext.w	a5,a5
    80205316:	db042703          	lw	a4,-592(s0)
    8020531a:	02f777bb          	remuw	a5,a4,a5
    8020531e:	daf42823          	sw	a5,-592(s0)

    byte_t buf[BSIZE];
    address_t temp_addr = (address_t)kvm_trans((address_t)&buf, getCurrentProc()->kpageTable);  // TODO 转换是必要的吗
    80205322:	dc840493          	addi	s1,s0,-568
    80205326:	ffffd097          	auipc	ra,0xffffd
    8020532a:	8a8080e7          	jalr	-1880(ra) # 80201bce <getCurrentProc>
    8020532e:	87aa                	mv	a5,a0
    80205330:	739c                	ld	a5,32(a5)
    80205332:	85be                	mv	a1,a5
    80205334:	8526                	mv	a0,s1
    80205336:	ffffc097          	auipc	ra,0xffffc
    8020533a:	85e080e7          	jalr	-1954(ra) # 80200b94 <kvm_trans>
    8020533e:	fca43823          	sd	a0,-48(s0)
    uint32_t current = 0;
    80205342:	fc042c23          	sw	zero,-40(s0)
    for (; current < len; ++sec) {
    80205346:	a8e5                	j	8020543e <clus_io+0x1dc>
        disk_read((uint8_t*)temp_addr, sec);
    80205348:	fd043783          	ld	a5,-48(s0)
    8020534c:	fdc42703          	lw	a4,-36(s0)
    80205350:	85ba                	mv	a1,a4
    80205352:	853e                	mv	a0,a5
    80205354:	00002097          	auipc	ra,0x2
    80205358:	5c0080e7          	jalr	1472(ra) # 80207914 <disk_read>

        uint32_t _len = __MIN(len - current, fat32.bpb.bytesPerSector - off);
    8020535c:	00022797          	auipc	a5,0x22
    80205360:	29478793          	addi	a5,a5,660 # 802275f0 <fat32>
    80205364:	679c                	ld	a5,8(a5)
    80205366:	83e1                	srli	a5,a5,0x18
    80205368:	9bfd                	andi	a5,a5,-1
    8020536a:	17c2                	slli	a5,a5,0x30
    8020536c:	93c1                	srli	a5,a5,0x30
    8020536e:	0007871b          	sext.w	a4,a5
    80205372:	db042783          	lw	a5,-592(s0)
    80205376:	40f707bb          	subw	a5,a4,a5
    8020537a:	0007869b          	sext.w	a3,a5
    8020537e:	da442703          	lw	a4,-604(s0)
    80205382:	fd842783          	lw	a5,-40(s0)
    80205386:	40f707bb          	subw	a5,a4,a5
    8020538a:	2781                	sext.w	a5,a5
    8020538c:	863e                	mv	a2,a5
    8020538e:	87b6                	mv	a5,a3
    80205390:	0007869b          	sext.w	a3,a5
    80205394:	0006071b          	sext.w	a4,a2
    80205398:	00d77363          	bgeu	a4,a3,8020539e <clus_io+0x13c>
    8020539c:	87b2                	mv	a5,a2
    8020539e:	fcf42623          	sw	a5,-52(s0)
        if (write) {
    802053a2:	db842783          	lw	a5,-584(s0)
    802053a6:	2781                	sext.w	a5,a5
    802053a8:	cb9d                	beqz	a5,802053de <clus_io+0x17c>
            memmove((void*)(buf + off), data, _len);
    802053aa:	db046783          	lwu	a5,-592(s0)
    802053ae:	dc840713          	addi	a4,s0,-568
    802053b2:	97ba                	add	a5,a5,a4
    802053b4:	fcc46703          	lwu	a4,-52(s0)
    802053b8:	863a                	mv	a2,a4
    802053ba:	da843583          	ld	a1,-600(s0)
    802053be:	853e                	mv	a0,a5
    802053c0:	ffffd097          	auipc	ra,0xffffd
    802053c4:	7bc080e7          	jalr	1980(ra) # 80202b7c <memmove>
            disk_write((uint8_t*)temp_addr, sec);
    802053c8:	fd043783          	ld	a5,-48(s0)
    802053cc:	fdc42703          	lw	a4,-36(s0)
    802053d0:	85ba                	mv	a1,a4
    802053d2:	853e                	mv	a0,a5
    802053d4:	00002097          	auipc	ra,0x2
    802053d8:	570080e7          	jalr	1392(ra) # 80207944 <disk_write>
    802053dc:	a005                	j	802053fc <clus_io+0x19a>
        } else
            memmove(data, (void*)(buf + off), _len);
    802053de:	db046783          	lwu	a5,-592(s0)
    802053e2:	dc840713          	addi	a4,s0,-568
    802053e6:	97ba                	add	a5,a5,a4
    802053e8:	fcc46703          	lwu	a4,-52(s0)
    802053ec:	863a                	mv	a2,a4
    802053ee:	85be                	mv	a1,a5
    802053f0:	da843503          	ld	a0,-600(s0)
    802053f4:	ffffd097          	auipc	ra,0xffffd
    802053f8:	788080e7          	jalr	1928(ra) # 80202b7c <memmove>

        off = (off + _len) % fat32.bpb.bytesPerSector;
    802053fc:	db042703          	lw	a4,-592(s0)
    80205400:	fcc42783          	lw	a5,-52(s0)
    80205404:	9fb9                	addw	a5,a5,a4
    80205406:	0007871b          	sext.w	a4,a5
    8020540a:	00022797          	auipc	a5,0x22
    8020540e:	1e678793          	addi	a5,a5,486 # 802275f0 <fat32>
    80205412:	679c                	ld	a5,8(a5)
    80205414:	83e1                	srli	a5,a5,0x18
    80205416:	9bfd                	andi	a5,a5,-1
    80205418:	17c2                	slli	a5,a5,0x30
    8020541a:	93c1                	srli	a5,a5,0x30
    8020541c:	2781                	sext.w	a5,a5
    8020541e:	02f777bb          	remuw	a5,a4,a5
    80205422:	daf42823          	sw	a5,-592(s0)
        current += _len;
    80205426:	fd842703          	lw	a4,-40(s0)
    8020542a:	fcc42783          	lw	a5,-52(s0)
    8020542e:	9fb9                	addw	a5,a5,a4
    80205430:	fcf42c23          	sw	a5,-40(s0)
    for (; current < len; ++sec) {
    80205434:	fdc42783          	lw	a5,-36(s0)
    80205438:	2785                	addiw	a5,a5,1
    8020543a:	fcf42e23          	sw	a5,-36(s0)
    8020543e:	fd842703          	lw	a4,-40(s0)
    80205442:	da442783          	lw	a5,-604(s0)
    80205446:	2701                	sext.w	a4,a4
    80205448:	2781                	sext.w	a5,a5
    8020544a:	eef76fe3          	bltu	a4,a5,80205348 <clus_io+0xe6>
    }
    return current;
    8020544e:	fd842783          	lw	a5,-40(s0)
}
    80205452:	853e                	mv	a0,a5
    80205454:	25813083          	ld	ra,600(sp)
    80205458:	25013403          	ld	s0,592(sp)
    8020545c:	24813483          	ld	s1,584(sp)
    80205460:	26010113          	addi	sp,sp,608
    80205464:	8082                	ret

0000000080205466 <clus_locate>:
 * @param off
 * @param alloc
 * @return uint32_t off在dir->curClus的偏移字节数
 */
int
clus_locate(dirent_t* dir, uint32_t off, bool alloc) {
    80205466:	7179                	addi	sp,sp,-48
    80205468:	f406                	sd	ra,40(sp)
    8020546a:	f022                	sd	s0,32(sp)
    8020546c:	1800                	addi	s0,sp,48
    8020546e:	fca43c23          	sd	a0,-40(s0)
    80205472:	87ae                	mv	a5,a1
    80205474:	8732                	mv	a4,a2
    80205476:	fcf42a23          	sw	a5,-44(s0)
    8020547a:	87ba                	mv	a5,a4
    8020547c:	fcf42823          	sw	a5,-48(s0)
    uint32_t clusNo = off / fat32.bytePerClus;  //相对于dir开始簇，是第几簇
    80205480:	00022797          	auipc	a5,0x22
    80205484:	17078793          	addi	a5,a5,368 # 802275f0 <fat32>
    80205488:	20c7a783          	lw	a5,524(a5)
    8020548c:	fd442703          	lw	a4,-44(s0)
    80205490:	02f757bb          	divuw	a5,a4,a5
    80205494:	fef42423          	sw	a5,-24(s0)
    if (clusNo < dir->clusCnt) {                //从头开始找
    80205498:	fd843783          	ld	a5,-40(s0)
    8020549c:	13c7a703          	lw	a4,316(a5)
    802054a0:	fe842783          	lw	a5,-24(s0)
    802054a4:	2781                	sext.w	a5,a5
    802054a6:	0ee7f163          	bgeu	a5,a4,80205588 <clus_locate+0x122>
        dir->curClus = dir->firstClus;
    802054aa:	fd843783          	ld	a5,-40(s0)
    802054ae:	1307a703          	lw	a4,304(a5)
    802054b2:	fd843783          	ld	a5,-40(s0)
    802054b6:	12e7ac23          	sw	a4,312(a5)
        dir->clusCnt = 0;
    802054ba:	fd843783          	ld	a5,-40(s0)
    802054be:	1207ae23          	sw	zero,316(a5)
    }
    while (clusNo > dir->clusCnt) {
    802054c2:	a0d9                	j	80205588 <clus_locate+0x122>
        uint32_t clus = fatTable_read(dir->curClus);
    802054c4:	fd843783          	ld	a5,-40(s0)
    802054c8:	1387a783          	lw	a5,312(a5)
    802054cc:	853e                	mv	a0,a5
    802054ce:	00000097          	auipc	ra,0x0
    802054d2:	b68080e7          	jalr	-1176(ra) # 80205036 <fatTable_read>
    802054d6:	87aa                	mv	a5,a0
    802054d8:	fef42623          	sw	a5,-20(s0)
        if (clus >= FAT32_EOC) {
    802054dc:	fec42783          	lw	a5,-20(s0)
    802054e0:	0007871b          	sext.w	a4,a5
    802054e4:	100007b7          	lui	a5,0x10000
    802054e8:	17dd                	addi	a5,a5,-9 # ffffff7 <_entry-0x70200009>
    802054ea:	06e7fe63          	bgeu	a5,a4,80205566 <clus_locate+0x100>
            if (alloc) {
    802054ee:	fd042783          	lw	a5,-48(s0)
    802054f2:	2781                	sext.w	a5,a5
    802054f4:	cbb9                	beqz	a5,8020554a <clus_locate+0xe4>
                clus = clus_alloc(dir->dev);
    802054f6:	fd843783          	ld	a5,-40(s0)
    802054fa:	1407c783          	lbu	a5,320(a5)
    802054fe:	853e                	mv	a0,a5
    80205500:	00000097          	auipc	ra,0x0
    80205504:	cd2080e7          	jalr	-814(ra) # 802051d2 <clus_alloc>
    80205508:	87aa                	mv	a5,a0
    8020550a:	fef42623          	sw	a5,-20(s0)
                fatTable_write(dir->curClus, clus);
    8020550e:	fd843783          	ld	a5,-40(s0)
    80205512:	1387a783          	lw	a5,312(a5)
    80205516:	fec42703          	lw	a4,-20(s0)
    8020551a:	85ba                	mv	a1,a4
    8020551c:	853e                	mv	a0,a5
    8020551e:	00000097          	auipc	ra,0x0
    80205522:	b74080e7          	jalr	-1164(ra) # 80205092 <fatTable_write>
                dir->size += fat32.bytePerClus;
    80205526:	fd843783          	ld	a5,-40(s0)
    8020552a:	1347a703          	lw	a4,308(a5)
    8020552e:	00022797          	auipc	a5,0x22
    80205532:	0c278793          	addi	a5,a5,194 # 802275f0 <fat32>
    80205536:	20c7a783          	lw	a5,524(a5)
    8020553a:	9fb9                	addw	a5,a5,a4
    8020553c:	0007871b          	sext.w	a4,a5
    80205540:	fd843783          	ld	a5,-40(s0)
    80205544:	12e7aa23          	sw	a4,308(a5)
    80205548:	a839                	j	80205566 <clus_locate+0x100>
            } else {
                dir->curClus = dir->firstClus;
    8020554a:	fd843783          	ld	a5,-40(s0)
    8020554e:	1307a703          	lw	a4,304(a5)
    80205552:	fd843783          	ld	a5,-40(s0)
    80205556:	12e7ac23          	sw	a4,312(a5)
                dir->clusCnt = 0;
    8020555a:	fd843783          	ld	a5,-40(s0)
    8020555e:	1207ae23          	sw	zero,316(a5)
                return -1;
    80205562:	57fd                	li	a5,-1
    80205564:	a0b9                	j	802055b2 <clus_locate+0x14c>
            }
        }
        dir->curClus = clus;
    80205566:	fd843783          	ld	a5,-40(s0)
    8020556a:	fec42703          	lw	a4,-20(s0)
    8020556e:	12e7ac23          	sw	a4,312(a5)
        ++dir->clusCnt;
    80205572:	fd843783          	ld	a5,-40(s0)
    80205576:	13c7a783          	lw	a5,316(a5)
    8020557a:	2785                	addiw	a5,a5,1
    8020557c:	0007871b          	sext.w	a4,a5
    80205580:	fd843783          	ld	a5,-40(s0)
    80205584:	12e7ae23          	sw	a4,316(a5)
    while (clusNo > dir->clusCnt) {
    80205588:	fd843783          	ld	a5,-40(s0)
    8020558c:	13c7a703          	lw	a4,316(a5)
    80205590:	fe842783          	lw	a5,-24(s0)
    80205594:	2781                	sext.w	a5,a5
    80205596:	f2f767e3          	bltu	a4,a5,802054c4 <clus_locate+0x5e>
    }

    return off % fat32.bytePerClus;
    8020559a:	00022797          	auipc	a5,0x22
    8020559e:	05678793          	addi	a5,a5,86 # 802275f0 <fat32>
    802055a2:	20c7a783          	lw	a5,524(a5)
    802055a6:	fd442703          	lw	a4,-44(s0)
    802055aa:	02f777bb          	remuw	a5,a4,a5
    802055ae:	2781                	sext.w	a5,a5
    802055b0:	2781                	sext.w	a5,a5
}
    802055b2:	853e                	mv	a0,a5
    802055b4:	70a2                	ld	ra,40(sp)
    802055b6:	7402                	ld	s0,32(sp)
    802055b8:	6145                	addi	sp,sp,48
    802055ba:	8082                	ret

00000000802055bc <formatName>:

char*
formatName(char* name) {
    802055bc:	7179                	addi	sp,sp,-48
    802055be:	f406                	sd	ra,40(sp)
    802055c0:	f022                	sd	s0,32(sp)
    802055c2:	1800                	addi	s0,sp,48
    802055c4:	fca43c23          	sd	a0,-40(s0)
    while (*name == ' ' || *name == '.')
    802055c8:	a031                	j	802055d4 <formatName+0x18>
        ++name;
    802055ca:	fd843783          	ld	a5,-40(s0)
    802055ce:	0785                	addi	a5,a5,1
    802055d0:	fcf43c23          	sd	a5,-40(s0)
    while (*name == ' ' || *name == '.')
    802055d4:	fd843783          	ld	a5,-40(s0)
    802055d8:	0007c783          	lbu	a5,0(a5)
    802055dc:	873e                	mv	a4,a5
    802055de:	02000793          	li	a5,32
    802055e2:	fef704e3          	beq	a4,a5,802055ca <formatName+0xe>
    802055e6:	fd843783          	ld	a5,-40(s0)
    802055ea:	0007c783          	lbu	a5,0(a5)
    802055ee:	873e                	mv	a4,a5
    802055f0:	02e00793          	li	a5,46
    802055f4:	fcf70be3          	beq	a4,a5,802055ca <formatName+0xe>
    char* p = name;
    802055f8:	fd843783          	ld	a5,-40(s0)
    802055fc:	fef43423          	sd	a5,-24(s0)
    for (; *p != '\0'; ++p) {
    80205600:	a83d                	j	8020563e <formatName+0x82>
        if (*p < 0x20 || (strchr(illegal, *p) != NULL))  // 0x20之前在ASCII中为控制字符
    80205602:	fe843783          	ld	a5,-24(s0)
    80205606:	0007c783          	lbu	a5,0(a5)
    8020560a:	873e                	mv	a4,a5
    8020560c:	47fd                	li	a5,31
    8020560e:	02e7f163          	bgeu	a5,a4,80205630 <formatName+0x74>
    80205612:	fe843783          	ld	a5,-24(s0)
    80205616:	0007c783          	lbu	a5,0(a5)
    8020561a:	85be                	mv	a1,a5
    8020561c:	00006517          	auipc	a0,0x6
    80205620:	fa450513          	addi	a0,a0,-92 # 8020b5c0 <illegal>
    80205624:	ffffd097          	auipc	ra,0xffffd
    80205628:	7fe080e7          	jalr	2046(ra) # 80202e22 <strchr>
    8020562c:	87aa                	mv	a5,a0
    8020562e:	c399                	beqz	a5,80205634 <formatName+0x78>
            return NULL;
    80205630:	4781                	li	a5,0
    80205632:	a0b9                	j	80205680 <formatName+0xc4>
    for (; *p != '\0'; ++p) {
    80205634:	fe843783          	ld	a5,-24(s0)
    80205638:	0785                	addi	a5,a5,1
    8020563a:	fef43423          	sd	a5,-24(s0)
    8020563e:	fe843783          	ld	a5,-24(s0)
    80205642:	0007c783          	lbu	a5,0(a5)
    80205646:	ffd5                	bnez	a5,80205602 <formatName+0x46>
    }
    while (p > name && *p == ' ')
    80205648:	a031                	j	80205654 <formatName+0x98>
        --p;
    8020564a:	fe843783          	ld	a5,-24(s0)
    8020564e:	17fd                	addi	a5,a5,-1
    80205650:	fef43423          	sd	a5,-24(s0)
    while (p > name && *p == ' ')
    80205654:	fe843703          	ld	a4,-24(s0)
    80205658:	fd843783          	ld	a5,-40(s0)
    8020565c:	00e7fb63          	bgeu	a5,a4,80205672 <formatName+0xb6>
    80205660:	fe843783          	ld	a5,-24(s0)
    80205664:	0007c783          	lbu	a5,0(a5)
    80205668:	873e                	mv	a4,a5
    8020566a:	02000793          	li	a5,32
    8020566e:	fcf70ee3          	beq	a4,a5,8020564a <formatName+0x8e>
    *(p + 1) = '\0';
    80205672:	fe843783          	ld	a5,-24(s0)
    80205676:	0785                	addi	a5,a5,1
    80205678:	00078023          	sb	zero,0(a5)
    return name;
    8020567c:	fd843783          	ld	a5,-40(s0)
}
    80205680:	853e                	mv	a0,a5
    80205682:	70a2                	ld	ra,40(sp)
    80205684:	7402                	ld	s0,32(sp)
    80205686:	6145                	addi	sp,sp,48
    80205688:	8082                	ret

000000008020568a <generateShortName>:

//格式 NAME    EXT
void
generateShortName(char* shortName, char* name) {
    8020568a:	715d                	addi	sp,sp,-80
    8020568c:	e486                	sd	ra,72(sp)
    8020568e:	e0a2                	sd	s0,64(sp)
    80205690:	0880                	addi	s0,sp,80
    80205692:	faa43c23          	sd	a0,-72(s0)
    80205696:	fab43823          	sd	a1,-80(s0)
    int j = 0;
    8020569a:	fe042623          	sw	zero,-20(s0)
    int len = strlen(name) - 1;
    8020569e:	fb043503          	ld	a0,-80(s0)
    802056a2:	ffffd097          	auipc	ra,0xffffd
    802056a6:	7ca080e7          	jalr	1994(ra) # 80202e6c <strlen>
    802056aa:	87aa                	mv	a5,a0
    802056ac:	2781                	sext.w	a5,a5
    802056ae:	37fd                	addiw	a5,a5,-1
    802056b0:	2781                	sext.w	a5,a5
    802056b2:	fcf42623          	sw	a5,-52(s0)
    int k;
    char c;
    for (k = len; k >= 0; --k)
    802056b6:	fcc42783          	lw	a5,-52(s0)
    802056ba:	fef42423          	sw	a5,-24(s0)
    802056be:	a015                	j	802056e2 <generateShortName+0x58>
        if (name[k] == '.')
    802056c0:	fe842783          	lw	a5,-24(s0)
    802056c4:	fb043703          	ld	a4,-80(s0)
    802056c8:	97ba                	add	a5,a5,a4
    802056ca:	0007c783          	lbu	a5,0(a5)
    802056ce:	873e                	mv	a4,a5
    802056d0:	02e00793          	li	a5,46
    802056d4:	00f70d63          	beq	a4,a5,802056ee <generateShortName+0x64>
    for (k = len; k >= 0; --k)
    802056d8:	fe842783          	lw	a5,-24(s0)
    802056dc:	37fd                	addiw	a5,a5,-1
    802056de:	fef42423          	sw	a5,-24(s0)
    802056e2:	fe842783          	lw	a5,-24(s0)
    802056e6:	2781                	sext.w	a5,a5
    802056e8:	fc07dce3          	bgez	a5,802056c0 <generateShortName+0x36>
    802056ec:	a011                	j	802056f0 <generateShortName+0x66>
            break;
    802056ee:	0001                	nop

    if (k < 0) {  //没有'.'
    802056f0:	fe842783          	lw	a5,-24(s0)
    802056f4:	2781                	sext.w	a5,a5
    802056f6:	0c07d563          	bgez	a5,802057c0 <generateShortName+0x136>
        for (int i = 0; i < 8; ++i) {
    802056fa:	fe042023          	sw	zero,-32(s0)
    802056fe:	a871                	j	8020579a <generateShortName+0x110>
            c = name[i];
    80205700:	fe042783          	lw	a5,-32(s0)
    80205704:	fb043703          	ld	a4,-80(s0)
    80205708:	97ba                	add	a5,a5,a4
    8020570a:	0007c783          	lbu	a5,0(a5)
    8020570e:	fef403a3          	sb	a5,-25(s0)
            if (c == ' ')
    80205712:	fe744783          	lbu	a5,-25(s0)
    80205716:	0ff7f713          	zext.b	a4,a5
    8020571a:	02000793          	li	a5,32
    8020571e:	06f70863          	beq	a4,a5,8020578e <generateShortName+0x104>
                continue;
            else if (c >= 'a' && c <= 'z')
    80205722:	fe744783          	lbu	a5,-25(s0)
    80205726:	0ff7f713          	zext.b	a4,a5
    8020572a:	06000793          	li	a5,96
    8020572e:	02e7f063          	bgeu	a5,a4,8020574e <generateShortName+0xc4>
    80205732:	fe744783          	lbu	a5,-25(s0)
    80205736:	0ff7f713          	zext.b	a4,a5
    8020573a:	07a00793          	li	a5,122
    8020573e:	00e7e863          	bltu	a5,a4,8020574e <generateShortName+0xc4>
                c += 'A' - 'a';
    80205742:	fe744783          	lbu	a5,-25(s0)
    80205746:	3781                	addiw	a5,a5,-32
    80205748:	fef403a3          	sb	a5,-25(s0)
    8020574c:	a015                	j	80205770 <generateShortName+0xe6>
            else if (strchr(illegal, c) != NULL)
    8020574e:	fe744783          	lbu	a5,-25(s0)
    80205752:	85be                	mv	a1,a5
    80205754:	00006517          	auipc	a0,0x6
    80205758:	e6c50513          	addi	a0,a0,-404 # 8020b5c0 <illegal>
    8020575c:	ffffd097          	auipc	ra,0xffffd
    80205760:	6c6080e7          	jalr	1734(ra) # 80202e22 <strchr>
    80205764:	87aa                	mv	a5,a0
    80205766:	c789                	beqz	a5,80205770 <generateShortName+0xe6>
                c = '_';
    80205768:	05f00793          	li	a5,95
    8020576c:	fef403a3          	sb	a5,-25(s0)
            shortName[j++] = c;
    80205770:	fec42783          	lw	a5,-20(s0)
    80205774:	0017871b          	addiw	a4,a5,1
    80205778:	fee42623          	sw	a4,-20(s0)
    8020577c:	873e                	mv	a4,a5
    8020577e:	fb843783          	ld	a5,-72(s0)
    80205782:	97ba                	add	a5,a5,a4
    80205784:	fe744703          	lbu	a4,-25(s0)
    80205788:	00e78023          	sb	a4,0(a5)
    8020578c:	a011                	j	80205790 <generateShortName+0x106>
                continue;
    8020578e:	0001                	nop
        for (int i = 0; i < 8; ++i) {
    80205790:	fe042783          	lw	a5,-32(s0)
    80205794:	2785                	addiw	a5,a5,1
    80205796:	fef42023          	sw	a5,-32(s0)
    8020579a:	fe042783          	lw	a5,-32(s0)
    8020579e:	0007871b          	sext.w	a4,a5
    802057a2:	479d                	li	a5,7
    802057a4:	f4e7dee3          	bge	a5,a4,80205700 <generateShortName+0x76>
        }
        memset(shortName + 8, ' ', 3);
    802057a8:	fb843783          	ld	a5,-72(s0)
    802057ac:	07a1                	addi	a5,a5,8
    802057ae:	460d                	li	a2,3
    802057b0:	02000593          	li	a1,32
    802057b4:	853e                	mv	a0,a5
    802057b6:	ffffd097          	auipc	ra,0xffffd
    802057ba:	370080e7          	jalr	880(ra) # 80202b26 <memset>
    802057be:	a2d9                	j	80205984 <generateShortName+0x2fa>
    } else {  //有'.'
        for (int i = 0; i < k; ++i) {
    802057c0:	fc042e23          	sw	zero,-36(s0)
    802057c4:	a871                	j	80205860 <generateShortName+0x1d6>
            char c = name[i];
    802057c6:	fdc42783          	lw	a5,-36(s0)
    802057ca:	fb043703          	ld	a4,-80(s0)
    802057ce:	97ba                	add	a5,a5,a4
    802057d0:	0007c783          	lbu	a5,0(a5)
    802057d4:	fcf40da3          	sb	a5,-37(s0)
            if (c == ' ')
    802057d8:	fdb44783          	lbu	a5,-37(s0)
    802057dc:	0ff7f713          	zext.b	a4,a5
    802057e0:	02000793          	li	a5,32
    802057e4:	06f70863          	beq	a4,a5,80205854 <generateShortName+0x1ca>
                continue;
            else if (c >= 'a' && c <= 'z')
    802057e8:	fdb44783          	lbu	a5,-37(s0)
    802057ec:	0ff7f713          	zext.b	a4,a5
    802057f0:	06000793          	li	a5,96
    802057f4:	02e7f063          	bgeu	a5,a4,80205814 <generateShortName+0x18a>
    802057f8:	fdb44783          	lbu	a5,-37(s0)
    802057fc:	0ff7f713          	zext.b	a4,a5
    80205800:	07a00793          	li	a5,122
    80205804:	00e7e863          	bltu	a5,a4,80205814 <generateShortName+0x18a>
                c += 'A' - 'a';
    80205808:	fdb44783          	lbu	a5,-37(s0)
    8020580c:	3781                	addiw	a5,a5,-32
    8020580e:	fcf40da3          	sb	a5,-37(s0)
    80205812:	a015                	j	80205836 <generateShortName+0x1ac>
            else if (strchr(illegal, c) != NULL)
    80205814:	fdb44783          	lbu	a5,-37(s0)
    80205818:	85be                	mv	a1,a5
    8020581a:	00006517          	auipc	a0,0x6
    8020581e:	da650513          	addi	a0,a0,-602 # 8020b5c0 <illegal>
    80205822:	ffffd097          	auipc	ra,0xffffd
    80205826:	600080e7          	jalr	1536(ra) # 80202e22 <strchr>
    8020582a:	87aa                	mv	a5,a0
    8020582c:	c789                	beqz	a5,80205836 <generateShortName+0x1ac>
                c = '_';
    8020582e:	05f00793          	li	a5,95
    80205832:	fcf40da3          	sb	a5,-37(s0)
            shortName[j++] = c;
    80205836:	fec42783          	lw	a5,-20(s0)
    8020583a:	0017871b          	addiw	a4,a5,1
    8020583e:	fee42623          	sw	a4,-20(s0)
    80205842:	873e                	mv	a4,a5
    80205844:	fb843783          	ld	a5,-72(s0)
    80205848:	97ba                	add	a5,a5,a4
    8020584a:	fdb44703          	lbu	a4,-37(s0)
    8020584e:	00e78023          	sb	a4,0(a5)
    80205852:	a011                	j	80205856 <generateShortName+0x1cc>
                continue;
    80205854:	0001                	nop
        for (int i = 0; i < k; ++i) {
    80205856:	fdc42783          	lw	a5,-36(s0)
    8020585a:	2785                	addiw	a5,a5,1
    8020585c:	fcf42e23          	sw	a5,-36(s0)
    80205860:	fdc42703          	lw	a4,-36(s0)
    80205864:	fe842783          	lw	a5,-24(s0)
    80205868:	2701                	sext.w	a4,a4
    8020586a:	2781                	sext.w	a5,a5
    8020586c:	f4f74de3          	blt	a4,a5,802057c6 <generateShortName+0x13c>
        }
        uint32_t temp = __MAX(SHORT_NAME_LEN - (len - k), 8);
    80205870:	fcc42703          	lw	a4,-52(s0)
    80205874:	fe842783          	lw	a5,-24(s0)
    80205878:	40f707bb          	subw	a5,a4,a5
    8020587c:	2781                	sext.w	a5,a5
    8020587e:	472d                	li	a4,11
    80205880:	40f707bb          	subw	a5,a4,a5
    80205884:	2781                	sext.w	a5,a5
    80205886:	0007869b          	sext.w	a3,a5
    8020588a:	4721                	li	a4,8
    8020588c:	00e6d363          	bge	a3,a4,80205892 <generateShortName+0x208>
    80205890:	47a1                	li	a5,8
    80205892:	2781                	sext.w	a5,a5
    80205894:	fcf42423          	sw	a5,-56(s0)
        memset(shortName + temp, ' ', temp - j);
    80205898:	fc846783          	lwu	a5,-56(s0)
    8020589c:	fb843703          	ld	a4,-72(s0)
    802058a0:	00f706b3          	add	a3,a4,a5
    802058a4:	fec42783          	lw	a5,-20(s0)
    802058a8:	fc842703          	lw	a4,-56(s0)
    802058ac:	40f707bb          	subw	a5,a4,a5
    802058b0:	2781                	sext.w	a5,a5
    802058b2:	1782                	slli	a5,a5,0x20
    802058b4:	9381                	srli	a5,a5,0x20
    802058b6:	863e                	mv	a2,a5
    802058b8:	02000593          	li	a1,32
    802058bc:	8536                	mv	a0,a3
    802058be:	ffffd097          	auipc	ra,0xffffd
    802058c2:	268080e7          	jalr	616(ra) # 80202b26 <memset>
        j = temp;
    802058c6:	fc842783          	lw	a5,-56(s0)
    802058ca:	fef42623          	sw	a5,-20(s0)
        for (int i = k + 1; i < len; ++i) {
    802058ce:	fe842783          	lw	a5,-24(s0)
    802058d2:	2785                	addiw	a5,a5,1
    802058d4:	fcf42a23          	sw	a5,-44(s0)
    802058d8:	a871                	j	80205974 <generateShortName+0x2ea>
            char c = name[i];
    802058da:	fd442783          	lw	a5,-44(s0)
    802058de:	fb043703          	ld	a4,-80(s0)
    802058e2:	97ba                	add	a5,a5,a4
    802058e4:	0007c783          	lbu	a5,0(a5)
    802058e8:	fcf409a3          	sb	a5,-45(s0)
            if (c == ' ')
    802058ec:	fd344783          	lbu	a5,-45(s0)
    802058f0:	0ff7f713          	zext.b	a4,a5
    802058f4:	02000793          	li	a5,32
    802058f8:	06f70863          	beq	a4,a5,80205968 <generateShortName+0x2de>
                continue;
            else if (c >= 'a' && c <= 'z')
    802058fc:	fd344783          	lbu	a5,-45(s0)
    80205900:	0ff7f713          	zext.b	a4,a5
    80205904:	06000793          	li	a5,96
    80205908:	02e7f063          	bgeu	a5,a4,80205928 <generateShortName+0x29e>
    8020590c:	fd344783          	lbu	a5,-45(s0)
    80205910:	0ff7f713          	zext.b	a4,a5
    80205914:	07a00793          	li	a5,122
    80205918:	00e7e863          	bltu	a5,a4,80205928 <generateShortName+0x29e>
                c += 'A' - 'a';
    8020591c:	fd344783          	lbu	a5,-45(s0)
    80205920:	3781                	addiw	a5,a5,-32
    80205922:	fcf409a3          	sb	a5,-45(s0)
    80205926:	a015                	j	8020594a <generateShortName+0x2c0>
            else if (strchr(illegal, c) != NULL)
    80205928:	fd344783          	lbu	a5,-45(s0)
    8020592c:	85be                	mv	a1,a5
    8020592e:	00006517          	auipc	a0,0x6
    80205932:	c9250513          	addi	a0,a0,-878 # 8020b5c0 <illegal>
    80205936:	ffffd097          	auipc	ra,0xffffd
    8020593a:	4ec080e7          	jalr	1260(ra) # 80202e22 <strchr>
    8020593e:	87aa                	mv	a5,a0
    80205940:	c789                	beqz	a5,8020594a <generateShortName+0x2c0>
                c = '_';
    80205942:	05f00793          	li	a5,95
    80205946:	fcf409a3          	sb	a5,-45(s0)
            shortName[j++] = c;
    8020594a:	fec42783          	lw	a5,-20(s0)
    8020594e:	0017871b          	addiw	a4,a5,1
    80205952:	fee42623          	sw	a4,-20(s0)
    80205956:	873e                	mv	a4,a5
    80205958:	fb843783          	ld	a5,-72(s0)
    8020595c:	97ba                	add	a5,a5,a4
    8020595e:	fd344703          	lbu	a4,-45(s0)
    80205962:	00e78023          	sb	a4,0(a5)
    80205966:	a011                	j	8020596a <generateShortName+0x2e0>
                continue;
    80205968:	0001                	nop
        for (int i = k + 1; i < len; ++i) {
    8020596a:	fd442783          	lw	a5,-44(s0)
    8020596e:	2785                	addiw	a5,a5,1
    80205970:	fcf42a23          	sw	a5,-44(s0)
    80205974:	fd442703          	lw	a4,-44(s0)
    80205978:	fcc42783          	lw	a5,-52(s0)
    8020597c:	2701                	sext.w	a4,a4
    8020597e:	2781                	sext.w	a5,a5
    80205980:	f4f74de3          	blt	a4,a5,802058da <generateShortName+0x250>
        }
    }
    shortName[SHORT_NAME_LEN] = '\0';
    80205984:	fb843783          	ld	a5,-72(s0)
    80205988:	07ad                	addi	a5,a5,11
    8020598a:	00078023          	sb	zero,0(a5)
}
    8020598e:	0001                	nop
    80205990:	60a6                	ld	ra,72(sp)
    80205992:	6406                	ld	s0,64(sp)
    80205994:	6161                	addi	sp,sp,80
    80205996:	8082                	ret

0000000080205998 <calCheckSum>:

uint8_t
calCheckSum(uint8_t* shortName) {
    80205998:	7179                	addi	sp,sp,-48
    8020599a:	f422                	sd	s0,40(sp)
    8020599c:	1800                	addi	s0,sp,48
    8020599e:	fca43c23          	sd	a0,-40(s0)
    uint8_t sum = 0;
    802059a2:	fe0407a3          	sb	zero,-17(s0)
    for (int i = 0; i < SHORT_NAME_LEN; ++i)
    802059a6:	fe042423          	sw	zero,-24(s0)
    802059aa:	a089                	j	802059ec <calCheckSum+0x54>
        sum = (sum & 1) ? 0x80 : 0 + (sum >> 1) + shortName[i];
    802059ac:	fef44783          	lbu	a5,-17(s0)
    802059b0:	2781                	sext.w	a5,a5
    802059b2:	8b85                	andi	a5,a5,1
    802059b4:	2781                	sext.w	a5,a5
    802059b6:	e395                	bnez	a5,802059da <calCheckSum+0x42>
    802059b8:	fef44783          	lbu	a5,-17(s0)
    802059bc:	0017d79b          	srliw	a5,a5,0x1
    802059c0:	0ff7f713          	zext.b	a4,a5
    802059c4:	fe842783          	lw	a5,-24(s0)
    802059c8:	fd843683          	ld	a3,-40(s0)
    802059cc:	97b6                	add	a5,a5,a3
    802059ce:	0007c783          	lbu	a5,0(a5)
    802059d2:	9fb9                	addw	a5,a5,a4
    802059d4:	0ff7f793          	zext.b	a5,a5
    802059d8:	a019                	j	802059de <calCheckSum+0x46>
    802059da:	08000793          	li	a5,128
    802059de:	fef407a3          	sb	a5,-17(s0)
    for (int i = 0; i < SHORT_NAME_LEN; ++i)
    802059e2:	fe842783          	lw	a5,-24(s0)
    802059e6:	2785                	addiw	a5,a5,1
    802059e8:	fef42423          	sw	a5,-24(s0)
    802059ec:	fe842783          	lw	a5,-24(s0)
    802059f0:	0007871b          	sext.w	a4,a5
    802059f4:	47a9                	li	a5,10
    802059f6:	fae7dbe3          	bge	a5,a4,802059ac <calCheckSum+0x14>
    return sum;
    802059fa:	fef44783          	lbu	a5,-17(s0)
}
    802059fe:	853e                	mv	a0,a5
    80205a00:	7422                	ld	s0,40(sp)
    80205a02:	6145                	addi	sp,sp,48
    80205a04:	8082                	ret

0000000080205a06 <skipElem>:
 * @param path 路径，结束后指向路径中的下一个 '/'
 * @param name 记录路径中两个 '/' 之间的文件名
 * @return char*
 */
char*
skipElem(char* path, char* name) {
    80205a06:	7179                	addi	sp,sp,-48
    80205a08:	f406                	sd	ra,40(sp)
    80205a0a:	f022                	sd	s0,32(sp)
    80205a0c:	1800                	addi	s0,sp,48
    80205a0e:	fca43c23          	sd	a0,-40(s0)
    80205a12:	fcb43823          	sd	a1,-48(s0)
    // skip '/'
    while (*path == '/')
    80205a16:	a031                	j	80205a22 <skipElem+0x1c>
        ++path;
    80205a18:	fd843783          	ld	a5,-40(s0)
    80205a1c:	0785                	addi	a5,a5,1
    80205a1e:	fcf43c23          	sd	a5,-40(s0)
    while (*path == '/')
    80205a22:	fd843783          	ld	a5,-40(s0)
    80205a26:	0007c783          	lbu	a5,0(a5)
    80205a2a:	873e                	mv	a4,a5
    80205a2c:	02f00793          	li	a5,47
    80205a30:	fef704e3          	beq	a4,a5,80205a18 <skipElem+0x12>
    if (*path == '\0')
    80205a34:	fd843783          	ld	a5,-40(s0)
    80205a38:	0007c783          	lbu	a5,0(a5)
    80205a3c:	e399                	bnez	a5,80205a42 <skipElem+0x3c>
        return NULL;
    80205a3e:	4781                	li	a5,0
    80205a40:	a045                	j	80205ae0 <skipElem+0xda>

    char* s = path;
    80205a42:	fd843783          	ld	a5,-40(s0)
    80205a46:	fef43023          	sd	a5,-32(s0)
    while (*path != '/' && *path != '\0')
    80205a4a:	a031                	j	80205a56 <skipElem+0x50>
        ++path;
    80205a4c:	fd843783          	ld	a5,-40(s0)
    80205a50:	0785                	addi	a5,a5,1
    80205a52:	fcf43c23          	sd	a5,-40(s0)
    while (*path != '/' && *path != '\0')
    80205a56:	fd843783          	ld	a5,-40(s0)
    80205a5a:	0007c783          	lbu	a5,0(a5)
    80205a5e:	873e                	mv	a4,a5
    80205a60:	02f00793          	li	a5,47
    80205a64:	00f70763          	beq	a4,a5,80205a72 <skipElem+0x6c>
    80205a68:	fd843783          	ld	a5,-40(s0)
    80205a6c:	0007c783          	lbu	a5,0(a5)
    80205a70:	fff1                	bnez	a5,80205a4c <skipElem+0x46>
    int len = path - s;
    80205a72:	fd843703          	ld	a4,-40(s0)
    80205a76:	fe043783          	ld	a5,-32(s0)
    80205a7a:	40f707b3          	sub	a5,a4,a5
    80205a7e:	fef42623          	sw	a5,-20(s0)
    if (len > FAT32_MAX_FILENAME)
    80205a82:	fec42783          	lw	a5,-20(s0)
    80205a86:	0007871b          	sext.w	a4,a5
    80205a8a:	0ff00793          	li	a5,255
    80205a8e:	00e7d663          	bge	a5,a4,80205a9a <skipElem+0x94>
        len = FAT32_MAX_FILENAME;
    80205a92:	0ff00793          	li	a5,255
    80205a96:	fef42623          	sw	a5,-20(s0)
    name[len] = '\0';
    80205a9a:	fec42783          	lw	a5,-20(s0)
    80205a9e:	fd043703          	ld	a4,-48(s0)
    80205aa2:	97ba                	add	a5,a5,a4
    80205aa4:	00078023          	sb	zero,0(a5)
    memmove(name, s, len);
    80205aa8:	fec42783          	lw	a5,-20(s0)
    80205aac:	863e                	mv	a2,a5
    80205aae:	fe043583          	ld	a1,-32(s0)
    80205ab2:	fd043503          	ld	a0,-48(s0)
    80205ab6:	ffffd097          	auipc	ra,0xffffd
    80205aba:	0c6080e7          	jalr	198(ra) # 80202b7c <memmove>
    while (*path == '/')
    80205abe:	a031                	j	80205aca <skipElem+0xc4>
        ++path;
    80205ac0:	fd843783          	ld	a5,-40(s0)
    80205ac4:	0785                	addi	a5,a5,1
    80205ac6:	fcf43c23          	sd	a5,-40(s0)
    while (*path == '/')
    80205aca:	fd843783          	ld	a5,-40(s0)
    80205ace:	0007c783          	lbu	a5,0(a5)
    80205ad2:	873e                	mv	a4,a5
    80205ad4:	02f00793          	li	a5,47
    80205ad8:	fef704e3          	beq	a4,a5,80205ac0 <skipElem+0xba>
    return path;
    80205adc:	fd843783          	ld	a5,-40(s0)
}
    80205ae0:	853e                	mv	a0,a5
    80205ae2:	70a2                	ld	ra,40(sp)
    80205ae4:	7402                	ld	s0,32(sp)
    80205ae6:	6145                	addi	sp,sp,48
    80205ae8:	8082                	ret

0000000080205aea <dentry_lock>:

void
dentry_lock(dirent_t* dentry) {
    80205aea:	1101                	addi	sp,sp,-32
    80205aec:	ec06                	sd	ra,24(sp)
    80205aee:	e822                	sd	s0,16(sp)
    80205af0:	1000                	addi	s0,sp,32
    80205af2:	fea43423          	sd	a0,-24(s0)
    if (dentry == NULL || dentry->ref < 1)
    80205af6:	fe843783          	ld	a5,-24(s0)
    80205afa:	c791                	beqz	a5,80205b06 <dentry_lock+0x1c>
    80205afc:	fe843783          	ld	a5,-24(s0)
    80205b00:	14c7a783          	lw	a5,332(a5)
    80205b04:	eb89                	bnez	a5,80205b16 <dentry_lock+0x2c>
        panic("dentry_lock");
    80205b06:	00006517          	auipc	a0,0x6
    80205b0a:	ae250513          	addi	a0,a0,-1310 # 8020b5e8 <illegal+0x28>
    80205b0e:	ffffd097          	auipc	ra,0xffffd
    80205b12:	ff6080e7          	jalr	-10(ra) # 80202b04 <panic>
    spinlock_acquire(&dentry->d_lk);
    80205b16:	fe843783          	ld	a5,-24(s0)
    80205b1a:	11878793          	addi	a5,a5,280
    80205b1e:	853e                	mv	a0,a5
    80205b20:	fffff097          	auipc	ra,0xfffff
    80205b24:	e32080e7          	jalr	-462(ra) # 80204952 <spinlock_acquire>
}
    80205b28:	0001                	nop
    80205b2a:	60e2                	ld	ra,24(sp)
    80205b2c:	6442                	ld	s0,16(sp)
    80205b2e:	6105                	addi	sp,sp,32
    80205b30:	8082                	ret

0000000080205b32 <dentry_unlock>:

void
dentry_unlock(dirent_t* dentry) {
    80205b32:	1101                	addi	sp,sp,-32
    80205b34:	ec06                	sd	ra,24(sp)
    80205b36:	e822                	sd	s0,16(sp)
    80205b38:	1000                	addi	s0,sp,32
    80205b3a:	fea43423          	sd	a0,-24(s0)
    if (dentry == NULL || dentry->ref < 1)
    80205b3e:	fe843783          	ld	a5,-24(s0)
    80205b42:	c791                	beqz	a5,80205b4e <dentry_unlock+0x1c>
    80205b44:	fe843783          	ld	a5,-24(s0)
    80205b48:	14c7a783          	lw	a5,332(a5)
    80205b4c:	eb89                	bnez	a5,80205b5e <dentry_unlock+0x2c>
        panic("dentry_lock");
    80205b4e:	00006517          	auipc	a0,0x6
    80205b52:	a9a50513          	addi	a0,a0,-1382 # 8020b5e8 <illegal+0x28>
    80205b56:	ffffd097          	auipc	ra,0xffffd
    80205b5a:	fae080e7          	jalr	-82(ra) # 80202b04 <panic>
    spinlock_release(&dentry->d_lk);
    80205b5e:	fe843783          	ld	a5,-24(s0)
    80205b62:	11878793          	addi	a5,a5,280
    80205b66:	853e                	mv	a0,a5
    80205b68:	fffff097          	auipc	ra,0xfffff
    80205b6c:	e60080e7          	jalr	-416(ra) # 802049c8 <spinlock_release>
}
    80205b70:	0001                	nop
    80205b72:	60e2                	ld	ra,24(sp)
    80205b74:	6442                	ld	s0,16(sp)
    80205b76:	6105                	addi	sp,sp,32
    80205b78:	8082                	ret

0000000080205b7a <pathCache_alloc>:
 * @brief caller need to hold lock of pathCache
 *
 * @return dirent_t*
 */
dirent_t*
pathCache_alloc(dirent_t* parent) {
    80205b7a:	7179                	addi	sp,sp,-48
    80205b7c:	f422                	sd	s0,40(sp)
    80205b7e:	1800                	addi	s0,sp,48
    80205b80:	fca43c23          	sd	a0,-40(s0)
    dirent_t* dir;
    for (dir = root.prev; dir != &root; dir = dir->prev)
    80205b84:	00325797          	auipc	a5,0x325
    80205b88:	48478793          	addi	a5,a5,1156 # 8052b008 <root>
    80205b8c:	1687b783          	ld	a5,360(a5)
    80205b90:	fef43423          	sd	a5,-24(s0)
    80205b94:	a8a1                	j	80205bec <pathCache_alloc+0x72>
        if (dir->ref == 0) {
    80205b96:	fe843783          	ld	a5,-24(s0)
    80205b9a:	14c7a783          	lw	a5,332(a5)
    80205b9e:	e3a9                	bnez	a5,80205be0 <pathCache_alloc+0x66>
            dir->ref = 1;
    80205ba0:	fe843783          	ld	a5,-24(s0)
    80205ba4:	4705                	li	a4,1
    80205ba6:	14e7a623          	sw	a4,332(a5)
            dir->dev = parent->dev;
    80205baa:	fd843783          	ld	a5,-40(s0)
    80205bae:	1407c703          	lbu	a4,320(a5)
    80205bb2:	fe843783          	ld	a5,-24(s0)
    80205bb6:	14e78023          	sb	a4,320(a5)
            dir->d_off = 0;
    80205bba:	fe843783          	ld	a5,-24(s0)
    80205bbe:	0007b423          	sd	zero,8(a5)
            dir->valid = FALSE;
    80205bc2:	fe843783          	ld	a5,-24(s0)
    80205bc6:	1407a423          	sw	zero,328(a5)
            dir->dirty = FALSE;
    80205bca:	fe843783          	ld	a5,-24(s0)
    80205bce:	1407a223          	sw	zero,324(a5)
            dir->d_type = 0;
    80205bd2:	fe843783          	ld	a5,-24(s0)
    80205bd6:	00078a23          	sb	zero,20(a5)
            return dir;
    80205bda:	fe843783          	ld	a5,-24(s0)
    80205bde:	a005                	j	80205bfe <pathCache_alloc+0x84>
    for (dir = root.prev; dir != &root; dir = dir->prev)
    80205be0:	fe843783          	ld	a5,-24(s0)
    80205be4:	1687b783          	ld	a5,360(a5)
    80205be8:	fef43423          	sd	a5,-24(s0)
    80205bec:	fe843703          	ld	a4,-24(s0)
    80205bf0:	00325797          	auipc	a5,0x325
    80205bf4:	41878793          	addi	a5,a5,1048 # 8052b008 <root>
    80205bf8:	f8f71fe3          	bne	a4,a5,80205b96 <pathCache_alloc+0x1c>
        }
    return NULL;
    80205bfc:	4781                	li	a5,0
}
    80205bfe:	853e                	mv	a0,a5
    80205c00:	7422                	ld	s0,40(sp)
    80205c02:	6145                	addi	sp,sp,48
    80205c04:	8082                	ret

0000000080205c06 <__fat32_read>:
 * @param off
 * @param len
 * @return int
 */
int
__fat32_read(dirent_t* dir, int user, void* dst, uint32_t off, size_t* len) {
    80205c06:	7139                	addi	sp,sp,-64
    80205c08:	fc06                	sd	ra,56(sp)
    80205c0a:	f822                	sd	s0,48(sp)
    80205c0c:	0080                	addi	s0,sp,64
    80205c0e:	fca43c23          	sd	a0,-40(s0)
    80205c12:	87ae                	mv	a5,a1
    80205c14:	fcc43423          	sd	a2,-56(s0)
    80205c18:	fce43023          	sd	a4,-64(s0)
    80205c1c:	fcf42a23          	sw	a5,-44(s0)
    80205c20:	87b6                	mv	a5,a3
    80205c22:	fcf42823          	sw	a5,-48(s0)
    if ((off > dir->size) || (dir->d_type & ATTR_DIRECTORY))
    80205c26:	fd843783          	ld	a5,-40(s0)
    80205c2a:	1347a703          	lw	a4,308(a5)
    80205c2e:	fd042783          	lw	a5,-48(s0)
    80205c32:	2781                	sext.w	a5,a5
    80205c34:	00f76a63          	bltu	a4,a5,80205c48 <__fat32_read+0x42>
    80205c38:	fd843783          	ld	a5,-40(s0)
    80205c3c:	0147c783          	lbu	a5,20(a5)
    80205c40:	2781                	sext.w	a5,a5
    80205c42:	8bc1                	andi	a5,a5,16
    80205c44:	2781                	sext.w	a5,a5
    80205c46:	c399                	beqz	a5,80205c4c <__fat32_read+0x46>
        return -E_INVAL;
    80205c48:	57f5                	li	a5,-3
    80205c4a:	aa01                	j	80205d5a <__fat32_read+0x154>

    uint32_t total = 0;
    80205c4c:	fe042623          	sw	zero,-20(s0)
    uint32_t lenTemp = *len;
    80205c50:	fc043783          	ld	a5,-64(s0)
    80205c54:	639c                	ld	a5,0(a5)
    80205c56:	fef42423          	sw	a5,-24(s0)
    *len = 0;
    80205c5a:	fc043783          	ld	a5,-64(s0)
    80205c5e:	0007b023          	sd	zero,0(a5)
    for (; dir->curClus < FAT32_EOC && total < lenTemp;) {
    80205c62:	a0e1                	j	80205d2a <__fat32_read+0x124>
        if (clus_locate(dir, off, 0) < 0)
    80205c64:	fd042783          	lw	a5,-48(s0)
    80205c68:	4601                	li	a2,0
    80205c6a:	85be                	mv	a1,a5
    80205c6c:	fd843503          	ld	a0,-40(s0)
    80205c70:	fffff097          	auipc	ra,0xfffff
    80205c74:	7f6080e7          	jalr	2038(ra) # 80205466 <clus_locate>
    80205c78:	87aa                	mv	a5,a0
    80205c7a:	0007d463          	bgez	a5,80205c82 <__fat32_read+0x7c>
            return -E_TOO_BIG;
    80205c7e:	57d1                	li	a5,-12
    80205c80:	a8e9                	j	80205d5a <__fat32_read+0x154>
        uint32_t _len = __MIN(fat32.bytePerClus - off % fat32.bytePerClus, lenTemp - total);
    80205c82:	fe842703          	lw	a4,-24(s0)
    80205c86:	fec42783          	lw	a5,-20(s0)
    80205c8a:	40f707bb          	subw	a5,a4,a5
    80205c8e:	0007861b          	sext.w	a2,a5
    80205c92:	00022797          	auipc	a5,0x22
    80205c96:	95e78793          	addi	a5,a5,-1698 # 802275f0 <fat32>
    80205c9a:	20c7a703          	lw	a4,524(a5)
    80205c9e:	00022797          	auipc	a5,0x22
    80205ca2:	95278793          	addi	a5,a5,-1710 # 802275f0 <fat32>
    80205ca6:	20c7a783          	lw	a5,524(a5)
    80205caa:	fd042683          	lw	a3,-48(s0)
    80205cae:	02f6f7bb          	remuw	a5,a3,a5
    80205cb2:	2781                	sext.w	a5,a5
    80205cb4:	40f707bb          	subw	a5,a4,a5
    80205cb8:	2781                	sext.w	a5,a5
    80205cba:	85be                	mv	a1,a5
    80205cbc:	87b2                	mv	a5,a2
    80205cbe:	0007869b          	sext.w	a3,a5
    80205cc2:	0005871b          	sext.w	a4,a1
    80205cc6:	00d77363          	bgeu	a4,a3,80205ccc <__fat32_read+0xc6>
    80205cca:	87ae                	mv	a5,a1
    80205ccc:	fef42223          	sw	a5,-28(s0)
        clus_io(dir->curClus, FALSE, user, dst + total, off % fat32.bytePerClus, _len);
    80205cd0:	fd843783          	ld	a5,-40(s0)
    80205cd4:	1387a503          	lw	a0,312(a5)
    80205cd8:	fec46783          	lwu	a5,-20(s0)
    80205cdc:	fc843703          	ld	a4,-56(s0)
    80205ce0:	00f706b3          	add	a3,a4,a5
    80205ce4:	00022797          	auipc	a5,0x22
    80205ce8:	90c78793          	addi	a5,a5,-1780 # 802275f0 <fat32>
    80205cec:	20c7a783          	lw	a5,524(a5)
    80205cf0:	fd042703          	lw	a4,-48(s0)
    80205cf4:	02f777bb          	remuw	a5,a4,a5
    80205cf8:	0007871b          	sext.w	a4,a5
    80205cfc:	fe442783          	lw	a5,-28(s0)
    80205d00:	fd442603          	lw	a2,-44(s0)
    80205d04:	4581                	li	a1,0
    80205d06:	fffff097          	auipc	ra,0xfffff
    80205d0a:	55c080e7          	jalr	1372(ra) # 80205262 <clus_io>
        // if (readLen < _len)
        //     break;
        total += _len;
    80205d0e:	fec42703          	lw	a4,-20(s0)
    80205d12:	fe442783          	lw	a5,-28(s0)
    80205d16:	9fb9                	addw	a5,a5,a4
    80205d18:	fef42623          	sw	a5,-20(s0)
        off += _len;
    80205d1c:	fd042703          	lw	a4,-48(s0)
    80205d20:	fe442783          	lw	a5,-28(s0)
    80205d24:	9fb9                	addw	a5,a5,a4
    80205d26:	fcf42823          	sw	a5,-48(s0)
    for (; dir->curClus < FAT32_EOC && total < lenTemp;) {
    80205d2a:	fd843783          	ld	a5,-40(s0)
    80205d2e:	1387a783          	lw	a5,312(a5)
    80205d32:	873e                	mv	a4,a5
    80205d34:	100007b7          	lui	a5,0x10000
    80205d38:	17dd                	addi	a5,a5,-9 # ffffff7 <_entry-0x70200009>
    80205d3a:	00e7ea63          	bltu	a5,a4,80205d4e <__fat32_read+0x148>
    80205d3e:	fec42703          	lw	a4,-20(s0)
    80205d42:	fe842783          	lw	a5,-24(s0)
    80205d46:	2701                	sext.w	a4,a4
    80205d48:	2781                	sext.w	a5,a5
    80205d4a:	f0f76de3          	bltu	a4,a5,80205c64 <__fat32_read+0x5e>
    }
    *len = total;
    80205d4e:	fec46703          	lwu	a4,-20(s0)
    80205d52:	fc043783          	ld	a5,-64(s0)
    80205d56:	e398                	sd	a4,0(a5)
    return 0;
    80205d58:	4781                	li	a5,0
}
    80205d5a:	853e                	mv	a0,a5
    80205d5c:	70e2                	ld	ra,56(sp)
    80205d5e:	7442                	ld	s0,48(sp)
    80205d60:	6121                	addi	sp,sp,64
    80205d62:	8082                	ret

0000000080205d64 <__fat32_write>:
 * @param off
 * @param len
 * @return int
 */
int
__fat32_write(dirent_t* dir, int user, void* src, uint32_t off, size_t* len) {
    80205d64:	7139                	addi	sp,sp,-64
    80205d66:	fc06                	sd	ra,56(sp)
    80205d68:	f822                	sd	s0,48(sp)
    80205d6a:	0080                	addi	s0,sp,64
    80205d6c:	fca43c23          	sd	a0,-40(s0)
    80205d70:	87ae                	mv	a5,a1
    80205d72:	fcc43423          	sd	a2,-56(s0)
    80205d76:	fce43023          	sd	a4,-64(s0)
    80205d7a:	fcf42a23          	sw	a5,-44(s0)
    80205d7e:	87b6                	mv	a5,a3
    80205d80:	fcf42823          	sw	a5,-48(s0)
    if ((off > dir->size) || (dir->d_type & ATTR_READ_ONLY))
    80205d84:	fd843783          	ld	a5,-40(s0)
    80205d88:	1347a703          	lw	a4,308(a5)
    80205d8c:	fd042783          	lw	a5,-48(s0)
    80205d90:	2781                	sext.w	a5,a5
    80205d92:	00f76a63          	bltu	a4,a5,80205da6 <__fat32_write+0x42>
    80205d96:	fd843783          	ld	a5,-40(s0)
    80205d9a:	0147c783          	lbu	a5,20(a5)
    80205d9e:	2781                	sext.w	a5,a5
    80205da0:	8b85                	andi	a5,a5,1
    80205da2:	2781                	sext.w	a5,a5
    80205da4:	c399                	beqz	a5,80205daa <__fat32_write+0x46>
        return -E_INVAL;
    80205da6:	57f5                	li	a5,-3
    80205da8:	a291                	j	80205eec <__fat32_write+0x188>
    if (dir->firstClus == 0) {
    80205daa:	fd843783          	ld	a5,-40(s0)
    80205dae:	1307a783          	lw	a5,304(a5)
    80205db2:	e3b1                	bnez	a5,80205df6 <__fat32_write+0x92>
        dir->curClus = dir->firstClus = clus_alloc(dir->dev);
    80205db4:	fd843783          	ld	a5,-40(s0)
    80205db8:	1407c783          	lbu	a5,320(a5)
    80205dbc:	853e                	mv	a0,a5
    80205dbe:	fffff097          	auipc	ra,0xfffff
    80205dc2:	414080e7          	jalr	1044(ra) # 802051d2 <clus_alloc>
    80205dc6:	87aa                	mv	a5,a0
    80205dc8:	0007871b          	sext.w	a4,a5
    80205dcc:	fd843783          	ld	a5,-40(s0)
    80205dd0:	12e7a823          	sw	a4,304(a5)
    80205dd4:	fd843783          	ld	a5,-40(s0)
    80205dd8:	1307a703          	lw	a4,304(a5)
    80205ddc:	fd843783          	ld	a5,-40(s0)
    80205de0:	12e7ac23          	sw	a4,312(a5)
        dir->clusCnt = 0;
    80205de4:	fd843783          	ld	a5,-40(s0)
    80205de8:	1207ae23          	sw	zero,316(a5)
        dir->dirty = 1;
    80205dec:	fd843783          	ld	a5,-40(s0)
    80205df0:	4705                	li	a4,1
    80205df2:	14e7a223          	sw	a4,324(a5)
    }

    uint32_t total, _len = 0;
    80205df6:	fe042423          	sw	zero,-24(s0)
    for (total = 0; total < *len;) {
    80205dfa:	fe042623          	sw	zero,-20(s0)
    80205dfe:	a055                	j	80205ea2 <__fat32_write+0x13e>
        clus_locate(dir, off, TRUE);
    80205e00:	fd042783          	lw	a5,-48(s0)
    80205e04:	4605                	li	a2,1
    80205e06:	85be                	mv	a1,a5
    80205e08:	fd843503          	ld	a0,-40(s0)
    80205e0c:	fffff097          	auipc	ra,0xfffff
    80205e10:	65a080e7          	jalr	1626(ra) # 80205466 <clus_locate>
        _len = __MIN(fat32.bytePerClus - off % fat32.bytePerClus, *len - total);
    80205e14:	fc043783          	ld	a5,-64(s0)
    80205e18:	6398                	ld	a4,0(a5)
    80205e1a:	fec46783          	lwu	a5,-20(s0)
    80205e1e:	40f70633          	sub	a2,a4,a5
    80205e22:	00021797          	auipc	a5,0x21
    80205e26:	7ce78793          	addi	a5,a5,1998 # 802275f0 <fat32>
    80205e2a:	20c7a703          	lw	a4,524(a5)
    80205e2e:	00021797          	auipc	a5,0x21
    80205e32:	7c278793          	addi	a5,a5,1986 # 802275f0 <fat32>
    80205e36:	20c7a783          	lw	a5,524(a5)
    80205e3a:	fd042683          	lw	a3,-48(s0)
    80205e3e:	02f6f7bb          	remuw	a5,a3,a5
    80205e42:	2781                	sext.w	a5,a5
    80205e44:	40f707bb          	subw	a5,a4,a5
    80205e48:	2781                	sext.w	a5,a5
    80205e4a:	02079713          	slli	a4,a5,0x20
    80205e4e:	9301                	srli	a4,a4,0x20
    80205e50:	87b2                	mv	a5,a2
    80205e52:	00f77363          	bgeu	a4,a5,80205e58 <__fat32_write+0xf4>
    80205e56:	87ba                	mv	a5,a4
    80205e58:	fef42423          	sw	a5,-24(s0)
        clus_io(dir->curClus, TRUE, user, src + total, off, _len);
    80205e5c:	fd843783          	ld	a5,-40(s0)
    80205e60:	1387a503          	lw	a0,312(a5)
    80205e64:	fec46783          	lwu	a5,-20(s0)
    80205e68:	fc843703          	ld	a4,-56(s0)
    80205e6c:	00f706b3          	add	a3,a4,a5
    80205e70:	fe842783          	lw	a5,-24(s0)
    80205e74:	fd042703          	lw	a4,-48(s0)
    80205e78:	fd442603          	lw	a2,-44(s0)
    80205e7c:	4585                	li	a1,1
    80205e7e:	fffff097          	auipc	ra,0xfffff
    80205e82:	3e4080e7          	jalr	996(ra) # 80205262 <clus_io>
        off += _len;
    80205e86:	fd042703          	lw	a4,-48(s0)
    80205e8a:	fe842783          	lw	a5,-24(s0)
    80205e8e:	9fb9                	addw	a5,a5,a4
    80205e90:	fcf42823          	sw	a5,-48(s0)
        total += _len;
    80205e94:	fec42703          	lw	a4,-20(s0)
    80205e98:	fe842783          	lw	a5,-24(s0)
    80205e9c:	9fb9                	addw	a5,a5,a4
    80205e9e:	fef42623          	sw	a5,-20(s0)
    for (total = 0; total < *len;) {
    80205ea2:	fec46703          	lwu	a4,-20(s0)
    80205ea6:	fc043783          	ld	a5,-64(s0)
    80205eaa:	639c                	ld	a5,0(a5)
    80205eac:	f4f76ae3          	bltu	a4,a5,80205e00 <__fat32_write+0x9c>
    }
    if ((*len > 0) && (off > dir->size)) {
    80205eb0:	fc043783          	ld	a5,-64(s0)
    80205eb4:	639c                	ld	a5,0(a5)
    80205eb6:	c78d                	beqz	a5,80205ee0 <__fat32_write+0x17c>
    80205eb8:	fd843783          	ld	a5,-40(s0)
    80205ebc:	1347a703          	lw	a4,308(a5)
    80205ec0:	fd042783          	lw	a5,-48(s0)
    80205ec4:	2781                	sext.w	a5,a5
    80205ec6:	00f77d63          	bgeu	a4,a5,80205ee0 <__fat32_write+0x17c>
        dir->size = off;  // TODO什么意思
    80205eca:	fd843783          	ld	a5,-40(s0)
    80205ece:	fd042703          	lw	a4,-48(s0)
    80205ed2:	12e7aa23          	sw	a4,308(a5)
        dir->dirty = TRUE;
    80205ed6:	fd843783          	ld	a5,-40(s0)
    80205eda:	4705                	li	a4,1
    80205edc:	14e7a223          	sw	a4,324(a5)
    }
    *len = total;
    80205ee0:	fec46703          	lwu	a4,-20(s0)
    80205ee4:	fc043783          	ld	a5,-64(s0)
    80205ee8:	e398                	sd	a4,0(a5)
    return 0;
    80205eea:	4781                	li	a5,0
}
    80205eec:	853e                	mv	a0,a5
    80205eee:	70e2                	ld	ra,56(sp)
    80205ef0:	7442                	ld	s0,48(sp)
    80205ef2:	6121                	addi	sp,sp,64
    80205ef4:	8082                	ret

0000000080205ef6 <__fat32_getDirEntry>:
 * @param parent
 * @param name
 * @return dirent_t*
 */
dirent_t*
__fat32_getDirEntry(dirent_t* parent, char* name) {
    80205ef6:	7179                	addi	sp,sp,-48
    80205ef8:	f406                	sd	ra,40(sp)
    80205efa:	f022                	sd	s0,32(sp)
    80205efc:	1800                	addi	s0,sp,48
    80205efe:	fca43c23          	sd	a0,-40(s0)
    80205f02:	fcb43823          	sd	a1,-48(s0)
    dirent_t* dir;
    spinlock_acquire(&pathCache.dentry_lk);
    80205f06:	00321517          	auipc	a0,0x321
    80205f0a:	90a50513          	addi	a0,a0,-1782 # 80526810 <pathCache>
    80205f0e:	fffff097          	auipc	ra,0xfffff
    80205f12:	a44080e7          	jalr	-1468(ra) # 80204952 <spinlock_acquire>

    if (name != NULL) {
    80205f16:	fd043783          	ld	a5,-48(s0)
    80205f1a:	cfd1                	beqz	a5,80205fb6 <__fat32_getDirEntry+0xc0>
        for (dir = root.next; dir != &root; dir = dir->next)
    80205f1c:	00325797          	auipc	a5,0x325
    80205f20:	0ec78793          	addi	a5,a5,236 # 8052b008 <root>
    80205f24:	1607b783          	ld	a5,352(a5)
    80205f28:	fef43423          	sd	a5,-24(s0)
    80205f2c:	a8ad                	j	80205fa6 <__fat32_getDirEntry+0xb0>
            if (dir->valid && (dir->parent == parent) && (strncmp(dir->d_name, name, FAT32_MAX_FILENAME) == 0)) {
    80205f2e:	fe843783          	ld	a5,-24(s0)
    80205f32:	1487a783          	lw	a5,328(a5)
    80205f36:	c3b5                	beqz	a5,80205f9a <__fat32_getDirEntry+0xa4>
    80205f38:	fe843783          	ld	a5,-24(s0)
    80205f3c:	1587b783          	ld	a5,344(a5)
    80205f40:	fd843703          	ld	a4,-40(s0)
    80205f44:	04f71b63          	bne	a4,a5,80205f9a <__fat32_getDirEntry+0xa4>
    80205f48:	fe843783          	ld	a5,-24(s0)
    80205f4c:	07d5                	addi	a5,a5,21
    80205f4e:	0ff00613          	li	a2,255
    80205f52:	fd043583          	ld	a1,-48(s0)
    80205f56:	853e                	mv	a0,a5
    80205f58:	ffffd097          	auipc	ra,0xffffd
    80205f5c:	ce8080e7          	jalr	-792(ra) # 80202c40 <strncmp>
    80205f60:	87aa                	mv	a5,a0
    80205f62:	ef85                	bnez	a5,80205f9a <__fat32_getDirEntry+0xa4>
                if (dir->ref == 0)
    80205f64:	fe843783          	ld	a5,-24(s0)
    80205f68:	14c7a783          	lw	a5,332(a5)
    80205f6c:	eb99                	bnez	a5,80205f82 <__fat32_getDirEntry+0x8c>
                    ++dir->parent->ref;
    80205f6e:	fe843783          	ld	a5,-24(s0)
    80205f72:	1587b783          	ld	a5,344(a5)
    80205f76:	14c7a703          	lw	a4,332(a5)
    80205f7a:	2705                	addiw	a4,a4,1
    80205f7c:	2701                	sext.w	a4,a4
    80205f7e:	14e7a623          	sw	a4,332(a5)
                ++dir->ref;  // TODO作用？
    80205f82:	fe843783          	ld	a5,-24(s0)
    80205f86:	14c7a783          	lw	a5,332(a5)
    80205f8a:	2785                	addiw	a5,a5,1
    80205f8c:	0007871b          	sext.w	a4,a5
    80205f90:	fe843783          	ld	a5,-24(s0)
    80205f94:	14e7a623          	sw	a4,332(a5)
                goto out;
    80205f98:	a03d                	j	80205fc6 <__fat32_getDirEntry+0xd0>
        for (dir = root.next; dir != &root; dir = dir->next)
    80205f9a:	fe843783          	ld	a5,-24(s0)
    80205f9e:	1607b783          	ld	a5,352(a5)
    80205fa2:	fef43423          	sd	a5,-24(s0)
    80205fa6:	fe843703          	ld	a4,-24(s0)
    80205faa:	00325797          	auipc	a5,0x325
    80205fae:	05e78793          	addi	a5,a5,94 # 8052b008 <root>
    80205fb2:	f6f71ee3          	bne	a4,a5,80205f2e <__fat32_getDirEntry+0x38>
            }
    }

    dir = pathCache_alloc(parent);
    80205fb6:	fd843503          	ld	a0,-40(s0)
    80205fba:	00000097          	auipc	ra,0x0
    80205fbe:	bc0080e7          	jalr	-1088(ra) # 80205b7a <pathCache_alloc>
    80205fc2:	fea43423          	sd	a0,-24(s0)

out:
    spinlock_release(&pathCache.dentry_lk);
    80205fc6:	00321517          	auipc	a0,0x321
    80205fca:	84a50513          	addi	a0,a0,-1974 # 80526810 <pathCache>
    80205fce:	fffff097          	auipc	ra,0xfffff
    80205fd2:	9fa080e7          	jalr	-1542(ra) # 802049c8 <spinlock_release>
    return dir;
    80205fd6:	fe843783          	ld	a5,-24(s0)
}
    80205fda:	853e                	mv	a0,a5
    80205fdc:	70a2                	ld	ra,40(sp)
    80205fde:	7402                	ld	s0,32(sp)
    80205fe0:	6145                	addi	sp,sp,48
    80205fe2:	8082                	ret

0000000080205fe4 <__fat32_dup>:

dirent_t*
__fat32_dup(dirent_t* dentry) {
    80205fe4:	1101                	addi	sp,sp,-32
    80205fe6:	ec06                	sd	ra,24(sp)
    80205fe8:	e822                	sd	s0,16(sp)
    80205fea:	1000                	addi	s0,sp,32
    80205fec:	fea43423          	sd	a0,-24(s0)
    if (dentry != NULL) {
    80205ff0:	fe843783          	ld	a5,-24(s0)
    80205ff4:	cf85                	beqz	a5,8020602c <__fat32_dup+0x48>
        spinlock_acquire(&pathCache.dentry_lk);
    80205ff6:	00321517          	auipc	a0,0x321
    80205ffa:	81a50513          	addi	a0,a0,-2022 # 80526810 <pathCache>
    80205ffe:	fffff097          	auipc	ra,0xfffff
    80206002:	954080e7          	jalr	-1708(ra) # 80204952 <spinlock_acquire>
        ++dentry->ref;
    80206006:	fe843783          	ld	a5,-24(s0)
    8020600a:	14c7a783          	lw	a5,332(a5)
    8020600e:	2785                	addiw	a5,a5,1
    80206010:	0007871b          	sext.w	a4,a5
    80206014:	fe843783          	ld	a5,-24(s0)
    80206018:	14e7a623          	sw	a4,332(a5)
        spinlock_release(&pathCache.dentry_lk);
    8020601c:	00320517          	auipc	a0,0x320
    80206020:	7f450513          	addi	a0,a0,2036 # 80526810 <pathCache>
    80206024:	fffff097          	auipc	ra,0xfffff
    80206028:	9a4080e7          	jalr	-1628(ra) # 802049c8 <spinlock_release>
    }
    return dentry;
    8020602c:	fe843783          	ld	a5,-24(s0)
}
    80206030:	853e                	mv	a0,a5
    80206032:	60e2                	ld	ra,24(sp)
    80206034:	6442                	ld	s0,16(sp)
    80206036:	6105                	addi	sp,sp,32
    80206038:	8082                	ret

000000008020603a <__fat32_trunc>:

int
__fat32_trunc(dirent_t* dentry) {
    8020603a:	7179                	addi	sp,sp,-48
    8020603c:	f406                	sd	ra,40(sp)
    8020603e:	f022                	sd	s0,32(sp)
    80206040:	1800                	addi	s0,sp,48
    80206042:	fca43c23          	sd	a0,-40(s0)
    for (uint32_t clus = dentry->firstClus; clus > 1 && clus < FAT32_EOC;) {
    80206046:	fd843783          	ld	a5,-40(s0)
    8020604a:	1307a783          	lw	a5,304(a5)
    8020604e:	fef42623          	sw	a5,-20(s0)
    80206052:	a035                	j	8020607e <__fat32_trunc+0x44>
        uint32_t next = fatTable_read(clus);
    80206054:	fec42783          	lw	a5,-20(s0)
    80206058:	853e                	mv	a0,a5
    8020605a:	fffff097          	auipc	ra,0xfffff
    8020605e:	fdc080e7          	jalr	-36(ra) # 80205036 <fatTable_read>
    80206062:	87aa                	mv	a5,a0
    80206064:	fef42423          	sw	a5,-24(s0)
        clus_free(clus);
    80206068:	fec42783          	lw	a5,-20(s0)
    8020606c:	853e                	mv	a0,a5
    8020606e:	fffff097          	auipc	ra,0xfffff
    80206072:	1ca080e7          	jalr	458(ra) # 80205238 <clus_free>
        clus = next;
    80206076:	fe842783          	lw	a5,-24(s0)
    8020607a:	fef42623          	sw	a5,-20(s0)
    for (uint32_t clus = dentry->firstClus; clus > 1 && clus < FAT32_EOC;) {
    8020607e:	fec42783          	lw	a5,-20(s0)
    80206082:	0007871b          	sext.w	a4,a5
    80206086:	4785                	li	a5,1
    80206088:	00e7fb63          	bgeu	a5,a4,8020609e <__fat32_trunc+0x64>
    8020608c:	fec42783          	lw	a5,-20(s0)
    80206090:	0007871b          	sext.w	a4,a5
    80206094:	100007b7          	lui	a5,0x10000
    80206098:	17dd                	addi	a5,a5,-9 # ffffff7 <_entry-0x70200009>
    8020609a:	fae7fde3          	bgeu	a5,a4,80206054 <__fat32_trunc+0x1a>
    }
    dentry->size = 0;
    8020609e:	fd843783          	ld	a5,-40(s0)
    802060a2:	1207aa23          	sw	zero,308(a5)
    dentry->firstClus = 0;
    802060a6:	fd843783          	ld	a5,-40(s0)
    802060aa:	1207a823          	sw	zero,304(a5)
    dentry->dirty = TRUE;
    802060ae:	fd843783          	ld	a5,-40(s0)
    802060b2:	4705                	li	a4,1
    802060b4:	14e7a223          	sw	a4,324(a5)
    return 0;  // TODO
    802060b8:	4781                	li	a5,0
}
    802060ba:	853e                	mv	a0,a5
    802060bc:	70a2                	ld	ra,40(sp)
    802060be:	7402                	ld	s0,32(sp)
    802060c0:	6145                	addi	sp,sp,48
    802060c2:	8082                	ret

00000000802060c4 <__fat32_fsync>:

int
__fat32_fsync(dirent_t* dentry) {
    802060c4:	715d                	addi	sp,sp,-80
    802060c6:	e486                	sd	ra,72(sp)
    802060c8:	e0a2                	sd	s0,64(sp)
    802060ca:	0880                	addi	s0,sp,80
    802060cc:	faa43c23          	sd	a0,-72(s0)
    if (dentry->dirty == FALSE || dentry->valid != TRUE)
    802060d0:	fb843783          	ld	a5,-72(s0)
    802060d4:	1447a783          	lw	a5,324(a5)
    802060d8:	cb89                	beqz	a5,802060ea <__fat32_fsync+0x26>
    802060da:	fb843783          	ld	a5,-72(s0)
    802060de:	1487a783          	lw	a5,328(a5)
    802060e2:	873e                	mv	a4,a5
    802060e4:	4785                	li	a5,1
    802060e6:	00f70463          	beq	a4,a5,802060ee <__fat32_fsync+0x2a>
        return 0;  // TODO
    802060ea:	4781                	li	a5,0
    802060ec:	a219                	j	802061f2 <__fat32_fsync+0x12e>
    uint32_t entCnt;
    uint32_t off = clus_locate(dentry->parent, dentry->d_off, FALSE);
    802060ee:	fb843783          	ld	a5,-72(s0)
    802060f2:	1587b703          	ld	a4,344(a5)
    802060f6:	fb843783          	ld	a5,-72(s0)
    802060fa:	679c                	ld	a5,8(a5)
    802060fc:	2781                	sext.w	a5,a5
    802060fe:	4601                	li	a2,0
    80206100:	85be                	mv	a1,a5
    80206102:	853a                	mv	a0,a4
    80206104:	fffff097          	auipc	ra,0xfffff
    80206108:	362080e7          	jalr	866(ra) # 80205466 <clus_locate>
    8020610c:	87aa                	mv	a5,a0
    8020610e:	fef42623          	sw	a5,-20(s0)
    clus_io(dentry->parent->curClus, FALSE, 0, (byte_t*)&entCnt, off, 1);
    80206112:	fb843783          	ld	a5,-72(s0)
    80206116:	1587b783          	ld	a5,344(a5)
    8020611a:	1387a503          	lw	a0,312(a5)
    8020611e:	fec42703          	lw	a4,-20(s0)
    80206122:	fe840693          	addi	a3,s0,-24
    80206126:	4785                	li	a5,1
    80206128:	4601                	li	a2,0
    8020612a:	4581                	li	a1,0
    8020612c:	fffff097          	auipc	ra,0xfffff
    80206130:	136080e7          	jalr	310(ra) # 80205262 <clus_io>
    entCnt &= ~LAST_LONG_ENTRY;  // TODO 什么意思
    80206134:	fe842783          	lw	a5,-24(s0)
    80206138:	fbf7f793          	andi	a5,a5,-65
    8020613c:	2781                	sext.w	a5,a5
    8020613e:	fef42423          	sw	a5,-24(s0)
    off = clus_locate(dentry->parent, dentry->d_off + entCnt * sizeof(fat32Entry_t), 0);
    80206142:	fb843783          	ld	a5,-72(s0)
    80206146:	1587b683          	ld	a3,344(a5)
    8020614a:	fb843783          	ld	a5,-72(s0)
    8020614e:	679c                	ld	a5,8(a5)
    80206150:	0007871b          	sext.w	a4,a5
    80206154:	fe842783          	lw	a5,-24(s0)
    80206158:	0057979b          	slliw	a5,a5,0x5
    8020615c:	2781                	sext.w	a5,a5
    8020615e:	9fb9                	addw	a5,a5,a4
    80206160:	2781                	sext.w	a5,a5
    80206162:	4601                	li	a2,0
    80206164:	85be                	mv	a1,a5
    80206166:	8536                	mv	a0,a3
    80206168:	fffff097          	auipc	ra,0xfffff
    8020616c:	2fe080e7          	jalr	766(ra) # 80205466 <clus_locate>
    80206170:	87aa                	mv	a5,a0
    80206172:	fef42623          	sw	a5,-20(s0)

    fat32Entry_t fentry;
    clus_io(dentry->parent->curClus, 0, 0, (byte_t*)&fentry, off, sizeof(fentry));
    80206176:	fb843783          	ld	a5,-72(s0)
    8020617a:	1587b783          	ld	a5,344(a5)
    8020617e:	1387a503          	lw	a0,312(a5)
    80206182:	fec42703          	lw	a4,-20(s0)
    80206186:	fc840693          	addi	a3,s0,-56
    8020618a:	02000793          	li	a5,32
    8020618e:	4601                	li	a2,0
    80206190:	4581                	li	a1,0
    80206192:	fffff097          	auipc	ra,0xfffff
    80206196:	0d0080e7          	jalr	208(ra) # 80205262 <clus_io>
    fentry.shortNameDir.start_high = (uint16_t)(dentry->firstClus >> 16);
    8020619a:	fb843783          	ld	a5,-72(s0)
    8020619e:	1307a783          	lw	a5,304(a5)
    802061a2:	0107d79b          	srliw	a5,a5,0x10
    802061a6:	2781                	sext.w	a5,a5
    802061a8:	17c2                	slli	a5,a5,0x30
    802061aa:	93c1                	srli	a5,a5,0x30
    802061ac:	fcf41e23          	sh	a5,-36(s0)
    fentry.shortNameDir.start_low = (uint16_t)(dentry->firstClus & 0xffff);
    802061b0:	fb843783          	ld	a5,-72(s0)
    802061b4:	1307a783          	lw	a5,304(a5)
    802061b8:	17c2                	slli	a5,a5,0x30
    802061ba:	93c1                	srli	a5,a5,0x30
    802061bc:	fef41123          	sh	a5,-30(s0)
    fentry.shortNameDir.size = dentry->size;
    802061c0:	fb843783          	ld	a5,-72(s0)
    802061c4:	1347a783          	lw	a5,308(a5)
    802061c8:	fef42223          	sw	a5,-28(s0)
    clus_io(dentry->parent->curClus, TRUE, 0, (byte_t*)&fentry, off, sizeof(fentry));
    802061cc:	fb843783          	ld	a5,-72(s0)
    802061d0:	1587b783          	ld	a5,344(a5)
    802061d4:	1387a503          	lw	a0,312(a5)
    802061d8:	fec42703          	lw	a4,-20(s0)
    802061dc:	fc840693          	addi	a3,s0,-56
    802061e0:	02000793          	li	a5,32
    802061e4:	4601                	li	a2,0
    802061e6:	4585                	li	a1,1
    802061e8:	fffff097          	auipc	ra,0xfffff
    802061ec:	07a080e7          	jalr	122(ra) # 80205262 <clus_io>
    return 0;
    802061f0:	4781                	li	a5,0
}
    802061f2:	853e                	mv	a0,a5
    802061f4:	60a6                	ld	ra,72(sp)
    802061f6:	6406                	ld	s0,64(sp)
    802061f8:	6161                	addi	sp,sp,80
    802061fa:	8082                	ret

00000000802061fc <__fat32_remove>:

int
__fat32_remove(dirent_t* dentry) {
    802061fc:	7139                	addi	sp,sp,-64
    802061fe:	fc06                	sd	ra,56(sp)
    80206200:	f822                	sd	s0,48(sp)
    80206202:	0080                	addi	s0,sp,64
    80206204:	fca43423          	sd	a0,-56(s0)
    if (dentry->valid != TRUE)
    80206208:	fc843783          	ld	a5,-56(s0)
    8020620c:	1487a783          	lw	a5,328(a5)
    80206210:	873e                	mv	a4,a5
    80206212:	4785                	li	a5,1
    80206214:	00f70463          	beq	a4,a5,8020621c <__fat32_remove+0x20>
        return 0;  // TODO
    80206218:	4781                	li	a5,0
    8020621a:	a8f1                	j	802062f6 <__fat32_remove+0xfa>
    uint32_t entCnt = 0;
    8020621c:	fe042023          	sw	zero,-32(s0)
    uint32_t off = dentry->d_off;  // off记录的是什么偏移
    80206220:	fc843783          	ld	a5,-56(s0)
    80206224:	679c                	ld	a5,8(a5)
    80206226:	fef42623          	sw	a5,-20(s0)
    uint32_t diskOff = clus_locate(dentry->parent, off, FALSE);
    8020622a:	fc843783          	ld	a5,-56(s0)
    8020622e:	1587b783          	ld	a5,344(a5)
    80206232:	fec42703          	lw	a4,-20(s0)
    80206236:	4601                	li	a2,0
    80206238:	85ba                	mv	a1,a4
    8020623a:	853e                	mv	a0,a5
    8020623c:	fffff097          	auipc	ra,0xfffff
    80206240:	22a080e7          	jalr	554(ra) # 80205466 <clus_locate>
    80206244:	87aa                	mv	a5,a0
    80206246:	fef42423          	sw	a5,-24(s0)
    clus_io(dentry->parent->curClus, FALSE, 0, (byte_t*)&entCnt, diskOff, 1);
    8020624a:	fc843783          	ld	a5,-56(s0)
    8020624e:	1587b783          	ld	a5,344(a5)
    80206252:	1387a503          	lw	a0,312(a5)
    80206256:	fe842703          	lw	a4,-24(s0)
    8020625a:	fe040693          	addi	a3,s0,-32
    8020625e:	4785                	li	a5,1
    80206260:	4601                	li	a2,0
    80206262:	4581                	li	a1,0
    80206264:	fffff097          	auipc	ra,0xfffff
    80206268:	ffe080e7          	jalr	-2(ra) # 80205262 <clus_io>
    entCnt &= ~LAST_LONG_ENTRY;
    8020626c:	fe042783          	lw	a5,-32(s0)
    80206270:	fbf7f793          	andi	a5,a5,-65
    80206274:	2781                	sext.w	a5,a5
    80206276:	fef42023          	sw	a5,-32(s0)
    uint8_t flag = EMPTY_ENTRY;
    8020627a:	5795                	li	a5,-27
    8020627c:	fcf40fa3          	sb	a5,-33(s0)
    for (int i = 0; i <= entCnt; ++i) {
    80206280:	fe042223          	sw	zero,-28(s0)
    80206284:	a8a9                	j	802062de <__fat32_remove+0xe2>
        clus_io(dentry->parent->curClus, TRUE, 0, (byte_t*)&flag, diskOff, 1);
    80206286:	fc843783          	ld	a5,-56(s0)
    8020628a:	1587b783          	ld	a5,344(a5)
    8020628e:	1387a503          	lw	a0,312(a5)
    80206292:	fe842703          	lw	a4,-24(s0)
    80206296:	fdf40693          	addi	a3,s0,-33
    8020629a:	4785                	li	a5,1
    8020629c:	4601                	li	a2,0
    8020629e:	4585                	li	a1,1
    802062a0:	fffff097          	auipc	ra,0xfffff
    802062a4:	fc2080e7          	jalr	-62(ra) # 80205262 <clus_io>
        off += 32;
    802062a8:	fec42783          	lw	a5,-20(s0)
    802062ac:	0207879b          	addiw	a5,a5,32
    802062b0:	fef42623          	sw	a5,-20(s0)
        diskOff = clus_locate(dentry->parent, off, FALSE);
    802062b4:	fc843783          	ld	a5,-56(s0)
    802062b8:	1587b783          	ld	a5,344(a5)
    802062bc:	fec42703          	lw	a4,-20(s0)
    802062c0:	4601                	li	a2,0
    802062c2:	85ba                	mv	a1,a4
    802062c4:	853e                	mv	a0,a5
    802062c6:	fffff097          	auipc	ra,0xfffff
    802062ca:	1a0080e7          	jalr	416(ra) # 80205466 <clus_locate>
    802062ce:	87aa                	mv	a5,a0
    802062d0:	fef42423          	sw	a5,-24(s0)
    for (int i = 0; i <= entCnt; ++i) {
    802062d4:	fe442783          	lw	a5,-28(s0)
    802062d8:	2785                	addiw	a5,a5,1
    802062da:	fef42223          	sw	a5,-28(s0)
    802062de:	fe442703          	lw	a4,-28(s0)
    802062e2:	fe042783          	lw	a5,-32(s0)
    802062e6:	fae7f0e3          	bgeu	a5,a4,80206286 <__fat32_remove+0x8a>
    }
    dentry->valid = ERROR;
    802062ea:	fc843783          	ld	a5,-56(s0)
    802062ee:	577d                	li	a4,-1
    802062f0:	14e7a423          	sw	a4,328(a5)
    return 0;  // TODO
    802062f4:	4781                	li	a5,0
}
    802062f6:	853e                	mv	a0,a5
    802062f8:	70e2                	ld	ra,56(sp)
    802062fa:	7442                	ld	s0,48(sp)
    802062fc:	6121                	addi	sp,sp,64
    802062fe:	8082                	ret

0000000080206300 <__fat32_fstat>:

int
__fat32_fstat(dirent_t* dentry, stat_t* status) {
    80206300:	1101                	addi	sp,sp,-32
    80206302:	ec06                	sd	ra,24(sp)
    80206304:	e822                	sd	s0,16(sp)
    80206306:	1000                	addi	s0,sp,32
    80206308:	fea43423          	sd	a0,-24(s0)
    8020630c:	feb43023          	sd	a1,-32(s0)
    memset(status, 0, sizeof(stat_t));
    80206310:	0b800613          	li	a2,184
    80206314:	4581                	li	a1,0
    80206316:	fe043503          	ld	a0,-32(s0)
    8020631a:	ffffd097          	auipc	ra,0xffffd
    8020631e:	80c080e7          	jalr	-2036(ra) # 80202b26 <memset>
    strncpy(status->name, dentry->d_name, STAT_MAX_NAME);
    80206322:	fe043783          	ld	a5,-32(s0)
    80206326:	09078713          	addi	a4,a5,144
    8020632a:	fe843783          	ld	a5,-24(s0)
    8020632e:	07d5                	addi	a5,a5,21
    80206330:	02000613          	li	a2,32
    80206334:	85be                	mv	a1,a5
    80206336:	853a                	mv	a0,a4
    80206338:	ffffd097          	auipc	ra,0xffffd
    8020633c:	a62080e7          	jalr	-1438(ra) # 80202d9a <strncpy>
    status->type = (dentry->d_type & ATTR_DIRECTORY) ? S_IFDIR : S_IFREG;
    80206340:	fe043783          	ld	a5,-32(s0)
    80206344:	08078423          	sb	zero,136(a5)
    status->dev = dentry->dev;
    80206348:	fe843783          	ld	a5,-24(s0)
    8020634c:	1407c783          	lbu	a5,320(a5)
    80206350:	0007871b          	sext.w	a4,a5
    80206354:	fe043783          	ld	a5,-32(s0)
    80206358:	08e7a623          	sw	a4,140(a5)
    status->st_size = dentry->size;
    8020635c:	fe843783          	ld	a5,-24(s0)
    80206360:	1347a783          	lw	a5,308(a5)
    80206364:	02079713          	slli	a4,a5,0x20
    80206368:	9301                	srli	a4,a4,0x20
    8020636a:	fe043783          	ld	a5,-32(s0)
    8020636e:	fb98                	sd	a4,48(a5)
    return 0;  // TODO
    80206370:	4781                	li	a5,0
}
    80206372:	853e                	mv	a0,a5
    80206374:	60e2                	ld	ra,24(sp)
    80206376:	6442                	ld	s0,16(sp)
    80206378:	6105                	addi	sp,sp,32
    8020637a:	8082                	ret

000000008020637c <__fat32_readEntryName>:

int
__fat32_readEntryName(char* buf, fat32Entry_t* fentry) {
    8020637c:	7139                	addi	sp,sp,-64
    8020637e:	fc22                	sd	s0,56(sp)
    80206380:	0080                	addi	s0,sp,64
    80206382:	fca43423          	sd	a0,-56(s0)
    80206386:	fcb43023          	sd	a1,-64(s0)
    if (fentry->longNameDir.attribute == ATTR_LONG_FILE_NAME) {
    8020638a:	fc043783          	ld	a5,-64(s0)
    8020638e:	00b7c783          	lbu	a5,11(a5)
    80206392:	873e                	mv	a4,a5
    80206394:	47bd                	li	a5,15
    80206396:	08f71263          	bne	a4,a5,8020641a <__fat32_readEntryName+0x9e>
        wchar_t* name = fentry->longNameDir.f5Name;
    8020639a:	fc043783          	ld	a5,-64(s0)
    8020639e:	0785                	addi	a5,a5,1
    802063a0:	fef43423          	sd	a5,-24(s0)
        for (int i = 0; i < LONG_NAME_LEN; ++i) {
    802063a4:	fe042223          	sw	zero,-28(s0)
    802063a8:	a08d                	j	8020640a <__fat32_readEntryName+0x8e>
            buf[i] = *name;
    802063aa:	fe843783          	ld	a5,-24(s0)
    802063ae:	0007d683          	lhu	a3,0(a5)
    802063b2:	fe442783          	lw	a5,-28(s0)
    802063b6:	fc843703          	ld	a4,-56(s0)
    802063ba:	97ba                	add	a5,a5,a4
    802063bc:	0ff6f713          	zext.b	a4,a3
    802063c0:	00e78023          	sb	a4,0(a5)
            ++name;
    802063c4:	fe843783          	ld	a5,-24(s0)
    802063c8:	0789                	addi	a5,a5,2
    802063ca:	fef43423          	sd	a5,-24(s0)
            if (i == 5 - 1)
    802063ce:	fe442783          	lw	a5,-28(s0)
    802063d2:	0007871b          	sext.w	a4,a5
    802063d6:	4791                	li	a5,4
    802063d8:	00f71863          	bne	a4,a5,802063e8 <__fat32_readEntryName+0x6c>
                name = fentry->longNameDir.m6Name;
    802063dc:	fc043783          	ld	a5,-64(s0)
    802063e0:	07b9                	addi	a5,a5,14
    802063e2:	fef43423          	sd	a5,-24(s0)
    802063e6:	a829                	j	80206400 <__fat32_readEntryName+0x84>
            else if (i == 11 - 1)
    802063e8:	fe442783          	lw	a5,-28(s0)
    802063ec:	0007871b          	sext.w	a4,a5
    802063f0:	47a9                	li	a5,10
    802063f2:	00f71763          	bne	a4,a5,80206400 <__fat32_readEntryName+0x84>
                name = fentry->longNameDir.e2Name;
    802063f6:	fc043783          	ld	a5,-64(s0)
    802063fa:	07f1                	addi	a5,a5,28
    802063fc:	fef43423          	sd	a5,-24(s0)
        for (int i = 0; i < LONG_NAME_LEN; ++i) {
    80206400:	fe442783          	lw	a5,-28(s0)
    80206404:	2785                	addiw	a5,a5,1
    80206406:	fef42223          	sw	a5,-28(s0)
    8020640a:	fe442783          	lw	a5,-28(s0)
    8020640e:	0007871b          	sext.w	a4,a5
    80206412:	47b1                	li	a5,12
    80206414:	f8e7dbe3          	bge	a5,a4,802063aa <__fat32_readEntryName+0x2e>
    80206418:	a0d5                	j	802064fc <__fat32_readEntryName+0x180>
        }
    } else {
        int i;
        for (i = 0; fentry->shortNameDir.name[i] != ' ' && i < 8; ++i)
    8020641a:	fe042023          	sw	zero,-32(s0)
    8020641e:	a025                	j	80206446 <__fat32_readEntryName+0xca>
            buf[i] = fentry->shortNameDir.name[i];
    80206420:	fe042783          	lw	a5,-32(s0)
    80206424:	fc843703          	ld	a4,-56(s0)
    80206428:	97ba                	add	a5,a5,a4
    8020642a:	fc043683          	ld	a3,-64(s0)
    8020642e:	fe042703          	lw	a4,-32(s0)
    80206432:	9736                	add	a4,a4,a3
    80206434:	00074703          	lbu	a4,0(a4)
    80206438:	00e78023          	sb	a4,0(a5)
        for (i = 0; fentry->shortNameDir.name[i] != ' ' && i < 8; ++i)
    8020643c:	fe042783          	lw	a5,-32(s0)
    80206440:	2785                	addiw	a5,a5,1
    80206442:	fef42023          	sw	a5,-32(s0)
    80206446:	fc043703          	ld	a4,-64(s0)
    8020644a:	fe042783          	lw	a5,-32(s0)
    8020644e:	97ba                	add	a5,a5,a4
    80206450:	0007c783          	lbu	a5,0(a5)
    80206454:	873e                	mv	a4,a5
    80206456:	02000793          	li	a5,32
    8020645a:	00f70963          	beq	a4,a5,8020646c <__fat32_readEntryName+0xf0>
    8020645e:	fe042783          	lw	a5,-32(s0)
    80206462:	0007871b          	sext.w	a4,a5
    80206466:	479d                	li	a5,7
    80206468:	fae7dce3          	bge	a5,a4,80206420 <__fat32_readEntryName+0xa4>
        if (fentry->shortNameDir.name[8] != ' ')
    8020646c:	fc043783          	ld	a5,-64(s0)
    80206470:	0087c783          	lbu	a5,8(a5)
    80206474:	873e                	mv	a4,a5
    80206476:	02000793          	li	a5,32
    8020647a:	02f70063          	beq	a4,a5,8020649a <__fat32_readEntryName+0x11e>
            buf[i++] = '.';
    8020647e:	fe042783          	lw	a5,-32(s0)
    80206482:	0017871b          	addiw	a4,a5,1
    80206486:	fee42023          	sw	a4,-32(s0)
    8020648a:	873e                	mv	a4,a5
    8020648c:	fc843783          	ld	a5,-56(s0)
    80206490:	97ba                	add	a5,a5,a4
    80206492:	02e00713          	li	a4,46
    80206496:	00e78023          	sb	a4,0(a5)
        for (int j = 8; j < SHORT_NAME_LEN; ++j, ++i) {
    8020649a:	47a1                	li	a5,8
    8020649c:	fcf42e23          	sw	a5,-36(s0)
    802064a0:	a0b9                	j	802064ee <__fat32_readEntryName+0x172>
            if (fentry->shortNameDir.name[j] == ' ')
    802064a2:	fc043703          	ld	a4,-64(s0)
    802064a6:	fdc42783          	lw	a5,-36(s0)
    802064aa:	97ba                	add	a5,a5,a4
    802064ac:	0007c783          	lbu	a5,0(a5)
    802064b0:	873e                	mv	a4,a5
    802064b2:	02000793          	li	a5,32
    802064b6:	02f70163          	beq	a4,a5,802064d8 <__fat32_readEntryName+0x15c>
                continue;
            buf[i] = fentry->shortNameDir.name[j];
    802064ba:	fe042783          	lw	a5,-32(s0)
    802064be:	fc843703          	ld	a4,-56(s0)
    802064c2:	97ba                	add	a5,a5,a4
    802064c4:	fc043683          	ld	a3,-64(s0)
    802064c8:	fdc42703          	lw	a4,-36(s0)
    802064cc:	9736                	add	a4,a4,a3
    802064ce:	00074703          	lbu	a4,0(a4)
    802064d2:	00e78023          	sb	a4,0(a5)
    802064d6:	a011                	j	802064da <__fat32_readEntryName+0x15e>
                continue;
    802064d8:	0001                	nop
        for (int j = 8; j < SHORT_NAME_LEN; ++j, ++i) {
    802064da:	fdc42783          	lw	a5,-36(s0)
    802064de:	2785                	addiw	a5,a5,1
    802064e0:	fcf42e23          	sw	a5,-36(s0)
    802064e4:	fe042783          	lw	a5,-32(s0)
    802064e8:	2785                	addiw	a5,a5,1
    802064ea:	fef42023          	sw	a5,-32(s0)
    802064ee:	fdc42783          	lw	a5,-36(s0)
    802064f2:	0007871b          	sext.w	a4,a5
    802064f6:	47a9                	li	a5,10
    802064f8:	fae7d5e3          	bge	a5,a4,802064a2 <__fat32_readEntryName+0x126>
        }
    }
    return 0;  // TODO
    802064fc:	4781                	li	a5,0
}
    802064fe:	853e                	mv	a0,a5
    80206500:	7462                	ld	s0,56(sp)
    80206502:	6121                	addi	sp,sp,64
    80206504:	8082                	ret

0000000080206506 <__fat32_readEntryInfo>:

int
__fat32_readEntryInfo(dirent_t* dentry, fat32Entry_t* fentry) {
    80206506:	1101                	addi	sp,sp,-32
    80206508:	ec22                	sd	s0,24(sp)
    8020650a:	1000                	addi	s0,sp,32
    8020650c:	fea43423          	sd	a0,-24(s0)
    80206510:	feb43023          	sd	a1,-32(s0)
    dentry->d_type = fentry->shortNameDir.attribute;
    80206514:	fe043783          	ld	a5,-32(s0)
    80206518:	00b7c703          	lbu	a4,11(a5)
    8020651c:	fe843783          	ld	a5,-24(s0)
    80206520:	00e78a23          	sb	a4,20(a5)
    dentry->size = fentry->shortNameDir.size;
    80206524:	fe043783          	ld	a5,-32(s0)
    80206528:	4fd8                	lw	a4,28(a5)
    8020652a:	fe843783          	ld	a5,-24(s0)
    8020652e:	12e7aa23          	sw	a4,308(a5)
    dentry->firstClus = ((uint32_t)(fentry->shortNameDir.start_high) << 16) | ((uint32_t)(fentry->shortNameDir.start_low));
    80206532:	fe043783          	ld	a5,-32(s0)
    80206536:	0147d783          	lhu	a5,20(a5)
    8020653a:	2781                	sext.w	a5,a5
    8020653c:	0107979b          	slliw	a5,a5,0x10
    80206540:	0007871b          	sext.w	a4,a5
    80206544:	fe043783          	ld	a5,-32(s0)
    80206548:	01a7d783          	lhu	a5,26(a5)
    8020654c:	2781                	sext.w	a5,a5
    8020654e:	8fd9                	or	a5,a5,a4
    80206550:	0007871b          	sext.w	a4,a5
    80206554:	fe843783          	ld	a5,-24(s0)
    80206558:	12e7a823          	sw	a4,304(a5)
    dentry->curClus = dentry->firstClus;
    8020655c:	fe843783          	ld	a5,-24(s0)
    80206560:	1307a703          	lw	a4,304(a5)
    80206564:	fe843783          	ld	a5,-24(s0)
    80206568:	12e7ac23          	sw	a4,312(a5)
    dentry->clusCnt = 0;
    8020656c:	fe843783          	ld	a5,-24(s0)
    80206570:	1207ae23          	sw	zero,316(a5)
    return 0;  // TODO
    80206574:	4781                	li	a5,0
}
    80206576:	853e                	mv	a0,a5
    80206578:	6462                	ld	s0,24(sp)
    8020657a:	6105                	addi	sp,sp,32
    8020657c:	8082                	ret

000000008020657e <__fat32_enExt>:
 * @param off
 * @param count 记录项数
 * @return int
 */
int
__fat32_enExt(dirent_t* dentry, dirent_t* tentry, uint32_t off, int* count) {  // TODO
    8020657e:	711d                	addi	sp,sp,-96
    80206580:	ec86                	sd	ra,88(sp)
    80206582:	e8a2                	sd	s0,80(sp)
    80206584:	1080                	addi	s0,sp,96
    80206586:	faa43c23          	sd	a0,-72(s0)
    8020658a:	fab43823          	sd	a1,-80(s0)
    8020658e:	87b2                	mv	a5,a2
    80206590:	fad43023          	sd	a3,-96(s0)
    80206594:	faf42623          	sw	a5,-84(s0)
    if (!(dentry->d_type & ATTR_DIRECTORY))
    80206598:	fb843783          	ld	a5,-72(s0)
    8020659c:	0147c783          	lbu	a5,20(a5)
    802065a0:	2781                	sext.w	a5,a5
    802065a2:	8bc1                	andi	a5,a5,16
    802065a4:	2781                	sext.w	a5,a5
    802065a6:	eb89                	bnez	a5,802065b8 <__fat32_enExt+0x3a>
        panic("__fat32_enExt not dir");
    802065a8:	00005517          	auipc	a0,0x5
    802065ac:	05050513          	addi	a0,a0,80 # 8020b5f8 <illegal+0x38>
    802065b0:	ffffc097          	auipc	ra,0xffffc
    802065b4:	554080e7          	jalr	1364(ra) # 80202b04 <panic>
    if (tentry->valid == TRUE)
    802065b8:	fb043783          	ld	a5,-80(s0)
    802065bc:	1487a783          	lw	a5,328(a5)
    802065c0:	873e                	mv	a4,a5
    802065c2:	4785                	li	a5,1
    802065c4:	00f71a63          	bne	a4,a5,802065d8 <__fat32_enExt+0x5a>
        panic("__fat32_enExt target valid");
    802065c8:	00005517          	auipc	a0,0x5
    802065cc:	04850513          	addi	a0,a0,72 # 8020b610 <illegal+0x50>
    802065d0:	ffffc097          	auipc	ra,0xffffc
    802065d4:	534080e7          	jalr	1332(ra) # 80202b04 <panic>
    if (off % 32 != 0)
    802065d8:	fac42783          	lw	a5,-84(s0)
    802065dc:	8bfd                	andi	a5,a5,31
    802065de:	2781                	sext.w	a5,a5
    802065e0:	cb89                	beqz	a5,802065f2 <__fat32_enExt+0x74>
        panic("__fat32_enExt offset not align");
    802065e2:	00005517          	auipc	a0,0x5
    802065e6:	04e50513          	addi	a0,a0,78 # 8020b630 <illegal+0x70>
    802065ea:	ffffc097          	auipc	ra,0xffffc
    802065ee:	51a080e7          	jalr	1306(ra) # 80202b04 <panic>
    if (dentry->valid != TRUE)
    802065f2:	fb843783          	ld	a5,-72(s0)
    802065f6:	1487a783          	lw	a5,328(a5)
    802065fa:	873e                	mv	a4,a5
    802065fc:	4785                	li	a5,1
    802065fe:	00f70463          	beq	a4,a5,80206606 <__fat32_enExt+0x88>
        return -E_INVAL;
    80206602:	57f5                	li	a5,-3
    80206604:	a241                	j	80206784 <__fat32_enExt+0x206>

    fat32Entry_t fentry;
    int cnt = 0;
    80206606:	fe042623          	sw	zero,-20(s0)
    memset(tentry->d_name, 0, FAT32_MAX_FILENAME + 1);
    8020660a:	fb043783          	ld	a5,-80(s0)
    8020660e:	07d5                	addi	a5,a5,21
    80206610:	10000613          	li	a2,256
    80206614:	4581                	li	a1,0
    80206616:	853e                	mv	a0,a5
    80206618:	ffffc097          	auipc	ra,0xffffc
    8020661c:	50e080e7          	jalr	1294(ra) # 80202b26 <memset>
    for (int diskOff = clus_locate(dentry, off, FALSE); diskOff >= 0;) {
    80206620:	fac42783          	lw	a5,-84(s0)
    80206624:	4601                	li	a2,0
    80206626:	85be                	mv	a1,a5
    80206628:	fb843503          	ld	a0,-72(s0)
    8020662c:	fffff097          	auipc	ra,0xfffff
    80206630:	e3a080e7          	jalr	-454(ra) # 80205466 <clus_locate>
    80206634:	87aa                	mv	a5,a0
    80206636:	fef42423          	sw	a5,-24(s0)
    8020663a:	aa3d                	j	80206778 <__fat32_enExt+0x1fa>
        uint32_t len = clus_io(dentry->curClus, FALSE, 0, (byte_t*)&fentry, diskOff, sizeof(fentry));
    8020663c:	fb843783          	ld	a5,-72(s0)
    80206640:	1387a503          	lw	a0,312(a5)
    80206644:	fe842703          	lw	a4,-24(s0)
    80206648:	fc040693          	addi	a3,s0,-64
    8020664c:	02000793          	li	a5,32
    80206650:	4601                	li	a2,0
    80206652:	4581                	li	a1,0
    80206654:	fffff097          	auipc	ra,0xfffff
    80206658:	c0e080e7          	jalr	-1010(ra) # 80205262 <clus_io>
    8020665c:	87aa                	mv	a5,a0
    8020665e:	fef42223          	sw	a5,-28(s0)
        if (len != sizeof(fentry))
    80206662:	fe442783          	lw	a5,-28(s0)
    80206666:	0007871b          	sext.w	a4,a5
    8020666a:	02000793          	li	a5,32
    8020666e:	00f70463          	beq	a4,a5,80206676 <__fat32_enExt+0xf8>
            return -1;  // TODO
    80206672:	57fd                	li	a5,-1
    80206674:	aa01                	j	80206784 <__fat32_enExt+0x206>
        if (fentry.longNameDir.sequence == EMPTY_ENTRY) {
    80206676:	fc044783          	lbu	a5,-64(s0)
    8020667a:	873e                	mv	a4,a5
    8020667c:	0e500793          	li	a5,229
    80206680:	00f71863          	bne	a4,a5,80206690 <__fat32_enExt+0x112>
            ++cnt;
    80206684:	fec42783          	lw	a5,-20(s0)
    80206688:	2785                	addiw	a5,a5,1
    8020668a:	fef42623          	sw	a5,-20(s0)
            continue;
    8020668e:	a0ed                	j	80206778 <__fat32_enExt+0x1fa>
        } else if (cnt != 0) {  //寻找连续空目录项的最后一项
    80206690:	fec42783          	lw	a5,-20(s0)
    80206694:	2781                	sext.w	a5,a5
    80206696:	cb81                	beqz	a5,802066a6 <__fat32_enExt+0x128>
            *count = cnt;
    80206698:	fa043783          	ld	a5,-96(s0)
    8020669c:	fec42703          	lw	a4,-20(s0)
    802066a0:	c398                	sw	a4,0(a5)
            return 0;
    802066a2:	4781                	li	a5,0
    802066a4:	a0c5                	j	80206784 <__fat32_enExt+0x206>
        }

        if (fentry.longNameDir.attribute == ATTR_LONG_FILE_NAME) {
    802066a6:	fcb44783          	lbu	a5,-53(s0)
    802066aa:	873e                	mv	a4,a5
    802066ac:	47bd                	li	a5,15
    802066ae:	08f71863          	bne	a4,a5,8020673e <__fat32_enExt+0x1c0>
            int seq = fentry.longNameDir.sequence & ~LAST_LONG_ENTRY;
    802066b2:	fc044783          	lbu	a5,-64(s0)
    802066b6:	2781                	sext.w	a5,a5
    802066b8:	fbf7f793          	andi	a5,a5,-65
    802066bc:	fef42023          	sw	a5,-32(s0)
            if (fentry.longNameDir.sequence & LAST_LONG_ENTRY) {
    802066c0:	fc044783          	lbu	a5,-64(s0)
    802066c4:	2781                	sext.w	a5,a5
    802066c6:	0407f793          	andi	a5,a5,64
    802066ca:	2781                	sext.w	a5,a5
    802066cc:	cb99                	beqz	a5,802066e2 <__fat32_enExt+0x164>
                *count = seq + 1;  // seq个长文件名目录项+1个短文件名目录项
    802066ce:	fe042783          	lw	a5,-32(s0)
    802066d2:	2785                	addiw	a5,a5,1
    802066d4:	0007871b          	sext.w	a4,a5
    802066d8:	fa043783          	ld	a5,-96(s0)
    802066dc:	c398                	sw	a4,0(a5)
                count = NULL;      //停止计数
    802066de:	fa043023          	sd	zero,-96(s0)
            }
            __fat32_readEntryName(tentry->d_name + (seq - 1) * LONG_NAME_LEN, &fentry);
    802066e2:	fb043783          	ld	a5,-80(s0)
    802066e6:	01578693          	addi	a3,a5,21
    802066ea:	fe042783          	lw	a5,-32(s0)
    802066ee:	37fd                	addiw	a5,a5,-1
    802066f0:	2781                	sext.w	a5,a5
    802066f2:	873e                	mv	a4,a5
    802066f4:	87ba                	mv	a5,a4
    802066f6:	0017979b          	slliw	a5,a5,0x1
    802066fa:	9fb9                	addw	a5,a5,a4
    802066fc:	0027979b          	slliw	a5,a5,0x2
    80206700:	9fb9                	addw	a5,a5,a4
    80206702:	2781                	sext.w	a5,a5
    80206704:	97b6                	add	a5,a5,a3
    80206706:	fc040713          	addi	a4,s0,-64
    8020670a:	85ba                	mv	a1,a4
    8020670c:	853e                	mv	a0,a5
    8020670e:	00000097          	auipc	ra,0x0
    80206712:	c6e080e7          	jalr	-914(ra) # 8020637c <__fat32_readEntryName>
                __fat32_readEntryName(tentry->d_name, &fentry);
            }
            __fat32_readEntryInfo(tentry, &fentry);
            return 1;
        }
        off += 32;
    80206716:	fac42783          	lw	a5,-84(s0)
    8020671a:	0207879b          	addiw	a5,a5,32
    8020671e:	faf42623          	sw	a5,-84(s0)
        diskOff = clus_locate(dentry, off, FALSE);
    80206722:	fac42783          	lw	a5,-84(s0)
    80206726:	4601                	li	a2,0
    80206728:	85be                	mv	a1,a5
    8020672a:	fb843503          	ld	a0,-72(s0)
    8020672e:	fffff097          	auipc	ra,0xfffff
    80206732:	d38080e7          	jalr	-712(ra) # 80205466 <clus_locate>
    80206736:	87aa                	mv	a5,a0
    80206738:	fef42423          	sw	a5,-24(s0)
    8020673c:	a835                	j	80206778 <__fat32_enExt+0x1fa>
            if (count != NULL) {
    8020673e:	fa043783          	ld	a5,-96(s0)
    80206742:	c385                	beqz	a5,80206762 <__fat32_enExt+0x1e4>
                *count = 1;
    80206744:	fa043783          	ld	a5,-96(s0)
    80206748:	4705                	li	a4,1
    8020674a:	c398                	sw	a4,0(a5)
                __fat32_readEntryName(tentry->d_name, &fentry);
    8020674c:	fb043783          	ld	a5,-80(s0)
    80206750:	07d5                	addi	a5,a5,21
    80206752:	fc040713          	addi	a4,s0,-64
    80206756:	85ba                	mv	a1,a4
    80206758:	853e                	mv	a0,a5
    8020675a:	00000097          	auipc	ra,0x0
    8020675e:	c22080e7          	jalr	-990(ra) # 8020637c <__fat32_readEntryName>
            __fat32_readEntryInfo(tentry, &fentry);
    80206762:	fc040793          	addi	a5,s0,-64
    80206766:	85be                	mv	a1,a5
    80206768:	fb043503          	ld	a0,-80(s0)
    8020676c:	00000097          	auipc	ra,0x0
    80206770:	d9a080e7          	jalr	-614(ra) # 80206506 <__fat32_readEntryInfo>
            return 1;
    80206774:	4785                	li	a5,1
    80206776:	a039                	j	80206784 <__fat32_enExt+0x206>
    for (int diskOff = clus_locate(dentry, off, FALSE); diskOff >= 0;) {
    80206778:	fe842783          	lw	a5,-24(s0)
    8020677c:	2781                	sext.w	a5,a5
    8020677e:	ea07dfe3          	bgez	a5,8020663c <__fat32_enExt+0xbe>
    }
    return -1;
    80206782:	57fd                	li	a5,-1
}
    80206784:	853e                	mv	a0,a5
    80206786:	60e6                	ld	ra,88(sp)
    80206788:	6446                	ld	s0,80(sp)
    8020678a:	6125                	addi	sp,sp,96
    8020678c:	8082                	ret

000000008020678e <__fat32_put>:

int
__fat32_put(dirent_t* dentry) {
    8020678e:	1101                	addi	sp,sp,-32
    80206790:	ec06                	sd	ra,24(sp)
    80206792:	e822                	sd	s0,16(sp)
    80206794:	1000                	addi	s0,sp,32
    80206796:	fea43423          	sd	a0,-24(s0)
    spinlock_acquire(&pathCache.dentry_lk);
    8020679a:	00320517          	auipc	a0,0x320
    8020679e:	07650513          	addi	a0,a0,118 # 80526810 <pathCache>
    802067a2:	ffffe097          	auipc	ra,0xffffe
    802067a6:	1b0080e7          	jalr	432(ra) # 80204952 <spinlock_acquire>

    if ((dentry != &root) && (dentry->valid) && (dentry->ref == 1)) {
    802067aa:	fe843703          	ld	a4,-24(s0)
    802067ae:	00325797          	auipc	a5,0x325
    802067b2:	85a78793          	addi	a5,a5,-1958 # 8052b008 <root>
    802067b6:	12f70c63          	beq	a4,a5,802068ee <__fat32_put+0x160>
    802067ba:	fe843783          	ld	a5,-24(s0)
    802067be:	1487a783          	lw	a5,328(a5)
    802067c2:	12078663          	beqz	a5,802068ee <__fat32_put+0x160>
    802067c6:	fe843783          	ld	a5,-24(s0)
    802067ca:	14c7a783          	lw	a5,332(a5)
    802067ce:	873e                	mv	a4,a5
    802067d0:	4785                	li	a5,1
    802067d2:	10f71e63          	bne	a4,a5,802068ee <__fat32_put+0x160>
        spinlock_acquire(&dentry->d_lk);
    802067d6:	fe843783          	ld	a5,-24(s0)
    802067da:	11878793          	addi	a5,a5,280
    802067de:	853e                	mv	a0,a5
    802067e0:	ffffe097          	auipc	ra,0xffffe
    802067e4:	172080e7          	jalr	370(ra) # 80204952 <spinlock_acquire>

        //将dentry插入到root.next处
        dentry->next->prev = dentry->prev;
    802067e8:	fe843783          	ld	a5,-24(s0)
    802067ec:	1607b783          	ld	a5,352(a5)
    802067f0:	fe843703          	ld	a4,-24(s0)
    802067f4:	16873703          	ld	a4,360(a4)
    802067f8:	16e7b423          	sd	a4,360(a5)
        dentry->prev->next = dentry->next;
    802067fc:	fe843783          	ld	a5,-24(s0)
    80206800:	1687b783          	ld	a5,360(a5)
    80206804:	fe843703          	ld	a4,-24(s0)
    80206808:	16073703          	ld	a4,352(a4)
    8020680c:	16e7b023          	sd	a4,352(a5)
        dentry->next = root.next;
    80206810:	00324797          	auipc	a5,0x324
    80206814:	7f878793          	addi	a5,a5,2040 # 8052b008 <root>
    80206818:	1607b703          	ld	a4,352(a5)
    8020681c:	fe843783          	ld	a5,-24(s0)
    80206820:	16e7b023          	sd	a4,352(a5)
        root.next->prev = dentry;
    80206824:	00324797          	auipc	a5,0x324
    80206828:	7e478793          	addi	a5,a5,2020 # 8052b008 <root>
    8020682c:	1607b783          	ld	a5,352(a5)
    80206830:	fe843703          	ld	a4,-24(s0)
    80206834:	16e7b423          	sd	a4,360(a5)
        root.next = dentry;
    80206838:	00324797          	auipc	a5,0x324
    8020683c:	7d078793          	addi	a5,a5,2000 # 8052b008 <root>
    80206840:	fe843703          	ld	a4,-24(s0)
    80206844:	16e7b023          	sd	a4,352(a5)

        // spinlock_release(&pathCache.dentry_lk);

        if (dentry->valid == ERROR)  // TODO
    80206848:	fe843783          	ld	a5,-24(s0)
    8020684c:	1487a783          	lw	a5,328(a5)
    80206850:	873e                	mv	a4,a5
    80206852:	57fd                	li	a5,-1
    80206854:	00f71963          	bne	a4,a5,80206866 <__fat32_put+0xd8>
            __fat32_trunc(dentry);
    80206858:	fe843503          	ld	a0,-24(s0)
    8020685c:	fffff097          	auipc	ra,0xfffff
    80206860:	7de080e7          	jalr	2014(ra) # 8020603a <__fat32_trunc>
    80206864:	a80d                	j	80206896 <__fat32_put+0x108>
        else {
            dentry_lock(dentry->parent);  // TODO! 可能遇到parent的锁已获取过的情况
    80206866:	fe843783          	ld	a5,-24(s0)
    8020686a:	1587b783          	ld	a5,344(a5)
    8020686e:	853e                	mv	a0,a5
    80206870:	fffff097          	auipc	ra,0xfffff
    80206874:	27a080e7          	jalr	634(ra) # 80205aea <dentry_lock>
            __fat32_fsync(dentry);
    80206878:	fe843503          	ld	a0,-24(s0)
    8020687c:	00000097          	auipc	ra,0x0
    80206880:	848080e7          	jalr	-1976(ra) # 802060c4 <__fat32_fsync>
            dentry_unlock(dentry->parent);
    80206884:	fe843783          	ld	a5,-24(s0)
    80206888:	1587b783          	ld	a5,344(a5)
    8020688c:	853e                	mv	a0,a5
    8020688e:	fffff097          	auipc	ra,0xfffff
    80206892:	2a4080e7          	jalr	676(ra) # 80205b32 <dentry_unlock>
        }

        // spinlock_acquire(&pathCache.dentry_lk);
        --dentry->ref;  // TODO ref到底什么含义
    80206896:	fe843783          	ld	a5,-24(s0)
    8020689a:	14c7a783          	lw	a5,332(a5)
    8020689e:	37fd                	addiw	a5,a5,-1
    802068a0:	0007871b          	sext.w	a4,a5
    802068a4:	fe843783          	ld	a5,-24(s0)
    802068a8:	14e7a623          	sw	a4,332(a5)
        spinlock_release(&dentry->d_lk);
    802068ac:	fe843783          	ld	a5,-24(s0)
    802068b0:	11878793          	addi	a5,a5,280
    802068b4:	853e                	mv	a0,a5
    802068b6:	ffffe097          	auipc	ra,0xffffe
    802068ba:	112080e7          	jalr	274(ra) # 802049c8 <spinlock_release>
        spinlock_release(&pathCache.dentry_lk);
    802068be:	00320517          	auipc	a0,0x320
    802068c2:	f5250513          	addi	a0,a0,-174 # 80526810 <pathCache>
    802068c6:	ffffe097          	auipc	ra,0xffffe
    802068ca:	102080e7          	jalr	258(ra) # 802049c8 <spinlock_release>
        if (dentry->ref == 0)
    802068ce:	fe843783          	ld	a5,-24(s0)
    802068d2:	14c7a783          	lw	a5,332(a5)
    802068d6:	eb91                	bnez	a5,802068ea <__fat32_put+0x15c>
            __fat32_put(dentry->parent);
    802068d8:	fe843783          	ld	a5,-24(s0)
    802068dc:	1587b783          	ld	a5,344(a5)
    802068e0:	853e                	mv	a0,a5
    802068e2:	00000097          	auipc	ra,0x0
    802068e6:	eac080e7          	jalr	-340(ra) # 8020678e <__fat32_put>
        return 0;
    802068ea:	4781                	li	a5,0
    802068ec:	a02d                	j	80206916 <__fat32_put+0x188>
    }
    --dentry->ref;
    802068ee:	fe843783          	ld	a5,-24(s0)
    802068f2:	14c7a783          	lw	a5,332(a5)
    802068f6:	37fd                	addiw	a5,a5,-1
    802068f8:	0007871b          	sext.w	a4,a5
    802068fc:	fe843783          	ld	a5,-24(s0)
    80206900:	14e7a623          	sw	a4,332(a5)
    spinlock_release(&pathCache.dentry_lk);
    80206904:	00320517          	auipc	a0,0x320
    80206908:	f0c50513          	addi	a0,a0,-244 # 80526810 <pathCache>
    8020690c:	ffffe097          	auipc	ra,0xffffe
    80206910:	0bc080e7          	jalr	188(ra) # 802049c8 <spinlock_release>
    return 0;
    80206914:	4781                	li	a5,0
}
    80206916:	853e                	mv	a0,a5
    80206918:	60e2                	ld	ra,24(sp)
    8020691a:	6442                	ld	s0,16(sp)
    8020691c:	6105                	addi	sp,sp,32
    8020691e:	8082                	ret

0000000080206920 <__fat32_lookupDir>:

dirent_t*
__fat32_lookupDir(dirent_t* dentry, char* name, uint32_t* offPtr) {
    80206920:	715d                	addi	sp,sp,-80
    80206922:	e486                	sd	ra,72(sp)
    80206924:	e0a2                	sd	s0,64(sp)
    80206926:	0880                	addi	s0,sp,80
    80206928:	fca43423          	sd	a0,-56(s0)
    8020692c:	fcb43023          	sd	a1,-64(s0)
    80206930:	fac43c23          	sd	a2,-72(s0)
    if (!(dentry->d_type & ATTR_DIRECTORY))
    80206934:	fc843783          	ld	a5,-56(s0)
    80206938:	0147c783          	lbu	a5,20(a5)
    8020693c:	2781                	sext.w	a5,a5
    8020693e:	8bc1                	andi	a5,a5,16
    80206940:	2781                	sext.w	a5,a5
    80206942:	eb89                	bnez	a5,80206954 <__fat32_lookupDir+0x34>
        panic("__fat32_lookup not dir");
    80206944:	00005517          	auipc	a0,0x5
    80206948:	d0c50513          	addi	a0,a0,-756 # 8020b650 <illegal+0x90>
    8020694c:	ffffc097          	auipc	ra,0xffffc
    80206950:	1b8080e7          	jalr	440(ra) # 80202b04 <panic>
    if (dentry->valid != TRUE)
    80206954:	fc843783          	ld	a5,-56(s0)
    80206958:	1487a783          	lw	a5,328(a5)
    8020695c:	873e                	mv	a4,a5
    8020695e:	4785                	li	a5,1
    80206960:	00f70463          	beq	a4,a5,80206968 <__fat32_lookupDir+0x48>
        return NULL;
    80206964:	4781                	li	a5,0
    80206966:	a2e5                	j	80206b4e <__fat32_lookupDir+0x22e>

    if (strncmp(name, ".", FAT32_MAX_FILENAME) == 0)
    80206968:	0ff00613          	li	a2,255
    8020696c:	00005597          	auipc	a1,0x5
    80206970:	cfc58593          	addi	a1,a1,-772 # 8020b668 <illegal+0xa8>
    80206974:	fc043503          	ld	a0,-64(s0)
    80206978:	ffffc097          	auipc	ra,0xffffc
    8020697c:	2c8080e7          	jalr	712(ra) # 80202c40 <strncmp>
    80206980:	87aa                	mv	a5,a0
    80206982:	eb89                	bnez	a5,80206994 <__fat32_lookupDir+0x74>
        return __fat32_dup(dentry);
    80206984:	fc843503          	ld	a0,-56(s0)
    80206988:	fffff097          	auipc	ra,0xfffff
    8020698c:	65c080e7          	jalr	1628(ra) # 80205fe4 <__fat32_dup>
    80206990:	87aa                	mv	a5,a0
    80206992:	aa75                	j	80206b4e <__fat32_lookupDir+0x22e>
    else if (strncmp(name, "..", FAT32_MAX_FILENAME) == 0) {
    80206994:	0ff00613          	li	a2,255
    80206998:	00005597          	auipc	a1,0x5
    8020699c:	cd858593          	addi	a1,a1,-808 # 8020b670 <illegal+0xb0>
    802069a0:	fc043503          	ld	a0,-64(s0)
    802069a4:	ffffc097          	auipc	ra,0xffffc
    802069a8:	29c080e7          	jalr	668(ra) # 80202c40 <strncmp>
    802069ac:	87aa                	mv	a5,a0
    802069ae:	ef95                	bnez	a5,802069ea <__fat32_lookupDir+0xca>
        if (dentry == &root)
    802069b0:	fc843703          	ld	a4,-56(s0)
    802069b4:	00324797          	auipc	a5,0x324
    802069b8:	65478793          	addi	a5,a5,1620 # 8052b008 <root>
    802069bc:	00f71c63          	bne	a4,a5,802069d4 <__fat32_lookupDir+0xb4>
            return __fat32_dup(&root);
    802069c0:	00324517          	auipc	a0,0x324
    802069c4:	64850513          	addi	a0,a0,1608 # 8052b008 <root>
    802069c8:	fffff097          	auipc	ra,0xfffff
    802069cc:	61c080e7          	jalr	1564(ra) # 80205fe4 <__fat32_dup>
    802069d0:	87aa                	mv	a5,a0
    802069d2:	aab5                	j	80206b4e <__fat32_lookupDir+0x22e>
        else
            return __fat32_dup(dentry->parent);
    802069d4:	fc843783          	ld	a5,-56(s0)
    802069d8:	1587b783          	ld	a5,344(a5)
    802069dc:	853e                	mv	a0,a5
    802069de:	fffff097          	auipc	ra,0xfffff
    802069e2:	606080e7          	jalr	1542(ra) # 80205fe4 <__fat32_dup>
    802069e6:	87aa                	mv	a5,a0
    802069e8:	a29d                	j	80206b4e <__fat32_lookupDir+0x22e>
    }

    dirent_t* tentry = __fat32_getDirEntry(dentry, name);
    802069ea:	fc043583          	ld	a1,-64(s0)
    802069ee:	fc843503          	ld	a0,-56(s0)
    802069f2:	fffff097          	auipc	ra,0xfffff
    802069f6:	504080e7          	jalr	1284(ra) # 80205ef6 <__fat32_getDirEntry>
    802069fa:	fea43023          	sd	a0,-32(s0)
    if (tentry != NULL && tentry->valid == TRUE)
    802069fe:	fe043783          	ld	a5,-32(s0)
    80206a02:	cf81                	beqz	a5,80206a1a <__fat32_lookupDir+0xfa>
    80206a04:	fe043783          	ld	a5,-32(s0)
    80206a08:	1487a783          	lw	a5,328(a5)
    80206a0c:	873e                	mv	a4,a5
    80206a0e:	4785                	li	a5,1
    80206a10:	00f71563          	bne	a4,a5,80206a1a <__fat32_lookupDir+0xfa>
        return tentry;
    80206a14:	fe043783          	ld	a5,-32(s0)
    80206a18:	aa1d                	j	80206b4e <__fat32_lookupDir+0x22e>

    int entCnt = (strlen(name) + LONG_NAME_LEN - 1) / LONG_NAME_LEN;
    80206a1a:	fc043503          	ld	a0,-64(s0)
    80206a1e:	ffffc097          	auipc	ra,0xffffc
    80206a22:	44e080e7          	jalr	1102(ra) # 80202e6c <strlen>
    80206a26:	87aa                	mv	a5,a0
    80206a28:	00c78713          	addi	a4,a5,12
    80206a2c:	47b5                	li	a5,13
    80206a2e:	02f757b3          	divu	a5,a4,a5
    80206a32:	fcf42e23          	sw	a5,-36(s0)
    int count = 0;
    80206a36:	fc042c23          	sw	zero,-40(s0)
    int type;
    uint32_t __off = 0;
    80206a3a:	fe042423          	sw	zero,-24(s0)
    clus_locate(dentry, 0, FALSE);
    80206a3e:	4601                	li	a2,0
    80206a40:	4581                	li	a1,0
    80206a42:	fc843503          	ld	a0,-56(s0)
    80206a46:	fffff097          	auipc	ra,0xfffff
    80206a4a:	a20080e7          	jalr	-1504(ra) # 80205466 <clus_locate>
    type = __fat32_enExt(dentry, tentry, __off, &count);
    80206a4e:	fd840713          	addi	a4,s0,-40
    80206a52:	fe842783          	lw	a5,-24(s0)
    80206a56:	86ba                	mv	a3,a4
    80206a58:	863e                	mv	a2,a5
    80206a5a:	fe043583          	ld	a1,-32(s0)
    80206a5e:	fc843503          	ld	a0,-56(s0)
    80206a62:	00000097          	auipc	ra,0x0
    80206a66:	b1c080e7          	jalr	-1252(ra) # 8020657e <__fat32_enExt>
    80206a6a:	87aa                	mv	a5,a0
    80206a6c:	fef42623          	sw	a5,-20(s0)
    while (type != -1) {
    80206a70:	a84d                	j	80206b22 <__fat32_lookupDir+0x202>
        if (type == 0) {  //空目录项
    80206a72:	fec42783          	lw	a5,-20(s0)
    80206a76:	2781                	sext.w	a5,a5
    80206a78:	e39d                	bnez	a5,80206a9e <__fat32_lookupDir+0x17e>
            if (offPtr != NULL && count >= entCnt) {
    80206a7a:	fb843783          	ld	a5,-72(s0)
    80206a7e:	c7b5                	beqz	a5,80206aea <__fat32_lookupDir+0x1ca>
    80206a80:	fd842703          	lw	a4,-40(s0)
    80206a84:	fdc42783          	lw	a5,-36(s0)
    80206a88:	2781                	sext.w	a5,a5
    80206a8a:	06f74063          	blt	a4,a5,80206aea <__fat32_lookupDir+0x1ca>
                *offPtr = __off;
    80206a8e:	fb843783          	ld	a5,-72(s0)
    80206a92:	fe842703          	lw	a4,-24(s0)
    80206a96:	c398                	sw	a4,0(a5)
                offPtr = NULL;
    80206a98:	fa043c23          	sd	zero,-72(s0)
    80206a9c:	a0b9                	j	80206aea <__fat32_lookupDir+0x1ca>
            }
        } else if (strncmp(name, tentry->d_name, FAT32_MAX_FILENAME) == 0) {
    80206a9e:	fe043783          	ld	a5,-32(s0)
    80206aa2:	07d5                	addi	a5,a5,21
    80206aa4:	0ff00613          	li	a2,255
    80206aa8:	85be                	mv	a1,a5
    80206aaa:	fc043503          	ld	a0,-64(s0)
    80206aae:	ffffc097          	auipc	ra,0xffffc
    80206ab2:	192080e7          	jalr	402(ra) # 80202c40 <strncmp>
    80206ab6:	87aa                	mv	a5,a0
    80206ab8:	eb8d                	bnez	a5,80206aea <__fat32_lookupDir+0x1ca>
            tentry->parent = __fat32_dup(dentry);
    80206aba:	fc843503          	ld	a0,-56(s0)
    80206abe:	fffff097          	auipc	ra,0xfffff
    80206ac2:	526080e7          	jalr	1318(ra) # 80205fe4 <__fat32_dup>
    80206ac6:	872a                	mv	a4,a0
    80206ac8:	fe043783          	ld	a5,-32(s0)
    80206acc:	14e7bc23          	sd	a4,344(a5)
            tentry->d_off = __off;
    80206ad0:	fe846703          	lwu	a4,-24(s0)
    80206ad4:	fe043783          	ld	a5,-32(s0)
    80206ad8:	e798                	sd	a4,8(a5)
            tentry->valid = TRUE;
    80206ada:	fe043783          	ld	a5,-32(s0)
    80206ade:	4705                	li	a4,1
    80206ae0:	14e7a423          	sw	a4,328(a5)
            return tentry;
    80206ae4:	fe043783          	ld	a5,-32(s0)
    80206ae8:	a09d                	j	80206b4e <__fat32_lookupDir+0x22e>
        }
        __off += count * sizeof(fat32Entry_t);
    80206aea:	fd842783          	lw	a5,-40(s0)
    80206aee:	2781                	sext.w	a5,a5
    80206af0:	0057979b          	slliw	a5,a5,0x5
    80206af4:	2781                	sext.w	a5,a5
    80206af6:	fe842703          	lw	a4,-24(s0)
    80206afa:	9fb9                	addw	a5,a5,a4
    80206afc:	fef42423          	sw	a5,-24(s0)
        type = __fat32_enExt(dentry, tentry, __off, &count);
    80206b00:	fd840713          	addi	a4,s0,-40
    80206b04:	fe842783          	lw	a5,-24(s0)
    80206b08:	86ba                	mv	a3,a4
    80206b0a:	863e                	mv	a2,a5
    80206b0c:	fe043583          	ld	a1,-32(s0)
    80206b10:	fc843503          	ld	a0,-56(s0)
    80206b14:	00000097          	auipc	ra,0x0
    80206b18:	a6a080e7          	jalr	-1430(ra) # 8020657e <__fat32_enExt>
    80206b1c:	87aa                	mv	a5,a0
    80206b1e:	fef42623          	sw	a5,-20(s0)
    while (type != -1) {
    80206b22:	fec42783          	lw	a5,-20(s0)
    80206b26:	0007871b          	sext.w	a4,a5
    80206b2a:	57fd                	li	a5,-1
    80206b2c:	f4f713e3          	bne	a4,a5,80206a72 <__fat32_lookupDir+0x152>
    }
    if (offPtr != NULL)
    80206b30:	fb843783          	ld	a5,-72(s0)
    80206b34:	c791                	beqz	a5,80206b40 <__fat32_lookupDir+0x220>
        *offPtr = __off;
    80206b36:	fb843783          	ld	a5,-72(s0)
    80206b3a:	fe842703          	lw	a4,-24(s0)
    80206b3e:	c398                	sw	a4,0(a5)
    __fat32_put(tentry);
    80206b40:	fe043503          	ld	a0,-32(s0)
    80206b44:	00000097          	auipc	ra,0x0
    80206b48:	c4a080e7          	jalr	-950(ra) # 8020678e <__fat32_put>
    return NULL;
    80206b4c:	4781                	li	a5,0
}
    80206b4e:	853e                	mv	a0,a5
    80206b50:	60a6                	ld	ra,72(sp)
    80206b52:	6406                	ld	s0,64(sp)
    80206b54:	6161                	addi	sp,sp,80
    80206b56:	8082                	ret

0000000080206b58 <__fat32_lookupPath>:
 * @param parent //TODO未知用途
 * @param name 存储路径最后的文件名，返回给调用者使用
 * @return dirent_t*
 */
dirent_t*
__fat32_lookupPath(char* path, bool parent, char* name) {
    80206b58:	7139                	addi	sp,sp,-64
    80206b5a:	fc06                	sd	ra,56(sp)
    80206b5c:	f822                	sd	s0,48(sp)
    80206b5e:	0080                	addi	s0,sp,64
    80206b60:	fca43c23          	sd	a0,-40(s0)
    80206b64:	87ae                	mv	a5,a1
    80206b66:	fcc43423          	sd	a2,-56(s0)
    80206b6a:	fcf42a23          	sw	a5,-44(s0)
    // assert(getCurrentProc()->fp->pwd->inodeType == inode_type_fat32_info);

    dirent_t *dentry, *next;
    if (*path == '/')
    80206b6e:	fd843783          	ld	a5,-40(s0)
    80206b72:	0007c783          	lbu	a5,0(a5)
    80206b76:	873e                	mv	a4,a5
    80206b78:	02f00793          	li	a5,47
    80206b7c:	00f71d63          	bne	a4,a5,80206b96 <__fat32_lookupPath+0x3e>
        dentry = __fat32_dup(&root);
    80206b80:	00324517          	auipc	a0,0x324
    80206b84:	48850513          	addi	a0,a0,1160 # 8052b008 <root>
    80206b88:	fffff097          	auipc	ra,0xfffff
    80206b8c:	45c080e7          	jalr	1116(ra) # 80205fe4 <__fat32_dup>
    80206b90:	fea43423          	sd	a0,-24(s0)
    80206b94:	a035                	j	80206bc0 <__fat32_lookupPath+0x68>
    else if (*path != '\0')
    80206b96:	fd843783          	ld	a5,-40(s0)
    80206b9a:	0007c783          	lbu	a5,0(a5)
    80206b9e:	cf99                	beqz	a5,80206bbc <__fat32_lookupPath+0x64>
        dentry = __fat32_dup(getCurrentProc()->cwd);
    80206ba0:	ffffb097          	auipc	ra,0xffffb
    80206ba4:	02e080e7          	jalr	46(ra) # 80201bce <getCurrentProc>
    80206ba8:	87aa                	mv	a5,a0
    80206baa:	7bdc                	ld	a5,176(a5)
    80206bac:	853e                	mv	a0,a5
    80206bae:	fffff097          	auipc	ra,0xfffff
    80206bb2:	436080e7          	jalr	1078(ra) # 80205fe4 <__fat32_dup>
    80206bb6:	fea43423          	sd	a0,-24(s0)
    80206bba:	a019                	j	80206bc0 <__fat32_lookupPath+0x68>
    else
        return NULL;
    80206bbc:	4781                	li	a5,0
    80206bbe:	a239                	j	80206ccc <__fat32_lookupPath+0x174>

    path = skipElem(path, name);
    80206bc0:	fc843583          	ld	a1,-56(s0)
    80206bc4:	fd843503          	ld	a0,-40(s0)
    80206bc8:	fffff097          	auipc	ra,0xfffff
    80206bcc:	e3e080e7          	jalr	-450(ra) # 80205a06 <skipElem>
    80206bd0:	fca43c23          	sd	a0,-40(s0)
    while (path != NULL) {
    80206bd4:	a8c1                	j	80206ca4 <__fat32_lookupPath+0x14c>
        dentry_lock(dentry);
    80206bd6:	fe843503          	ld	a0,-24(s0)
    80206bda:	fffff097          	auipc	ra,0xfffff
    80206bde:	f10080e7          	jalr	-240(ra) # 80205aea <dentry_lock>

        if (!(dentry->d_type & ATTR_DIRECTORY)) {
    80206be2:	fe843783          	ld	a5,-24(s0)
    80206be6:	0147c783          	lbu	a5,20(a5)
    80206bea:	2781                	sext.w	a5,a5
    80206bec:	8bc1                	andi	a5,a5,16
    80206bee:	2781                	sext.w	a5,a5
    80206bf0:	ef99                	bnez	a5,80206c0e <__fat32_lookupPath+0xb6>
            dentry_unlock(dentry);
    80206bf2:	fe843503          	ld	a0,-24(s0)
    80206bf6:	fffff097          	auipc	ra,0xfffff
    80206bfa:	f3c080e7          	jalr	-196(ra) # 80205b32 <dentry_unlock>
            __fat32_put(dentry);
    80206bfe:	fe843503          	ld	a0,-24(s0)
    80206c02:	00000097          	auipc	ra,0x0
    80206c06:	b8c080e7          	jalr	-1140(ra) # 8020678e <__fat32_put>
            return NULL;
    80206c0a:	4781                	li	a5,0
    80206c0c:	a0c1                	j	80206ccc <__fat32_lookupPath+0x174>
        }
        if (parent == TRUE && *path == '\0') {
    80206c0e:	fd442783          	lw	a5,-44(s0)
    80206c12:	0007871b          	sext.w	a4,a5
    80206c16:	4785                	li	a5,1
    80206c18:	02f71063          	bne	a4,a5,80206c38 <__fat32_lookupPath+0xe0>
    80206c1c:	fd843783          	ld	a5,-40(s0)
    80206c20:	0007c783          	lbu	a5,0(a5)
    80206c24:	eb91                	bnez	a5,80206c38 <__fat32_lookupPath+0xe0>
            dentry_unlock(dentry);
    80206c26:	fe843503          	ld	a0,-24(s0)
    80206c2a:	fffff097          	auipc	ra,0xfffff
    80206c2e:	f08080e7          	jalr	-248(ra) # 80205b32 <dentry_unlock>
            return dentry;
    80206c32:	fe843783          	ld	a5,-24(s0)
    80206c36:	a859                	j	80206ccc <__fat32_lookupPath+0x174>
        }

        next = __fat32_lookupDir(dentry, name, 0);
    80206c38:	4601                	li	a2,0
    80206c3a:	fc843583          	ld	a1,-56(s0)
    80206c3e:	fe843503          	ld	a0,-24(s0)
    80206c42:	00000097          	auipc	ra,0x0
    80206c46:	cde080e7          	jalr	-802(ra) # 80206920 <__fat32_lookupDir>
    80206c4a:	fea43023          	sd	a0,-32(s0)
        if (next == NULL) {
    80206c4e:	fe043783          	ld	a5,-32(s0)
    80206c52:	ef99                	bnez	a5,80206c70 <__fat32_lookupPath+0x118>
            dentry_unlock(dentry);  // TODO dentry的锁似乎已释放
    80206c54:	fe843503          	ld	a0,-24(s0)
    80206c58:	fffff097          	auipc	ra,0xfffff
    80206c5c:	eda080e7          	jalr	-294(ra) # 80205b32 <dentry_unlock>
            __fat32_put(dentry);
    80206c60:	fe843503          	ld	a0,-24(s0)
    80206c64:	00000097          	auipc	ra,0x0
    80206c68:	b2a080e7          	jalr	-1238(ra) # 8020678e <__fat32_put>
            return NULL;
    80206c6c:	4781                	li	a5,0
    80206c6e:	a8b9                	j	80206ccc <__fat32_lookupPath+0x174>
        }
        dentry_unlock(dentry);  // TODO dentry的锁似乎已释放
    80206c70:	fe843503          	ld	a0,-24(s0)
    80206c74:	fffff097          	auipc	ra,0xfffff
    80206c78:	ebe080e7          	jalr	-322(ra) # 80205b32 <dentry_unlock>
        __fat32_put(dentry);
    80206c7c:	fe843503          	ld	a0,-24(s0)
    80206c80:	00000097          	auipc	ra,0x0
    80206c84:	b0e080e7          	jalr	-1266(ra) # 8020678e <__fat32_put>
        dentry = next;
    80206c88:	fe043783          	ld	a5,-32(s0)
    80206c8c:	fef43423          	sd	a5,-24(s0)
        path = skipElem(path, name);
    80206c90:	fc843583          	ld	a1,-56(s0)
    80206c94:	fd843503          	ld	a0,-40(s0)
    80206c98:	fffff097          	auipc	ra,0xfffff
    80206c9c:	d6e080e7          	jalr	-658(ra) # 80205a06 <skipElem>
    80206ca0:	fca43c23          	sd	a0,-40(s0)
    while (path != NULL) {
    80206ca4:	fd843783          	ld	a5,-40(s0)
    80206ca8:	f79d                	bnez	a5,80206bd6 <__fat32_lookupPath+0x7e>
    }
    if (parent == TRUE) {
    80206caa:	fd442783          	lw	a5,-44(s0)
    80206cae:	0007871b          	sext.w	a4,a5
    80206cb2:	4785                	li	a5,1
    80206cb4:	00f71a63          	bne	a4,a5,80206cc8 <__fat32_lookupPath+0x170>
        __fat32_put(dentry);
    80206cb8:	fe843503          	ld	a0,-24(s0)
    80206cbc:	00000097          	auipc	ra,0x0
    80206cc0:	ad2080e7          	jalr	-1326(ra) # 8020678e <__fat32_put>
        return NULL;
    80206cc4:	4781                	li	a5,0
    80206cc6:	a019                	j	80206ccc <__fat32_lookupPath+0x174>
    }
    return dentry;
    80206cc8:	fe843783          	ld	a5,-24(s0)
}
    80206ccc:	853e                	mv	a0,a5
    80206cce:	70e2                	ld	ra,56(sp)
    80206cd0:	7442                	ld	s0,48(sp)
    80206cd2:	6121                	addi	sp,sp,64
    80206cd4:	8082                	ret

0000000080206cd6 <__fat32_create>:
 * @param entry
 * @param off
 * @return int
 */
int
__fat32_create(dirent_t* dir, dirent_t* entry, uint32_t off) {
    80206cd6:	7175                	addi	sp,sp,-144
    80206cd8:	e506                	sd	ra,136(sp)
    80206cda:	e122                	sd	s0,128(sp)
    80206cdc:	0900                	addi	s0,sp,144
    80206cde:	f8a43423          	sd	a0,-120(s0)
    80206ce2:	f8b43023          	sd	a1,-128(s0)
    80206ce6:	87b2                	mv	a5,a2
    80206ce8:	f6f42e23          	sw	a5,-132(s0)
    if (!(dir->d_type & ATTR_DIRECTORY) || (off % sizeof(fat32Entry_t) != 0))
    80206cec:	f8843783          	ld	a5,-120(s0)
    80206cf0:	0147c783          	lbu	a5,20(a5)
    80206cf4:	2781                	sext.w	a5,a5
    80206cf6:	8bc1                	andi	a5,a5,16
    80206cf8:	2781                	sext.w	a5,a5
    80206cfa:	c791                	beqz	a5,80206d06 <__fat32_create+0x30>
    80206cfc:	f7c42783          	lw	a5,-132(s0)
    80206d00:	8bfd                	andi	a5,a5,31
    80206d02:	2781                	sext.w	a5,a5
    80206d04:	c399                	beqz	a5,80206d0a <__fat32_create+0x34>
        return -E_INVAL;
    80206d06:	57f5                	li	a5,-3
    80206d08:	a4fd                	j	80206ff6 <__fat32_create+0x320>
    fat32Entry_t fentry;
    memset(&fentry, 0, sizeof(fat32Dentry_t));
    80206d0a:	fa840793          	addi	a5,s0,-88
    80206d0e:	02000613          	li	a2,32
    80206d12:	4581                	li	a1,0
    80206d14:	853e                	mv	a0,a5
    80206d16:	ffffc097          	auipc	ra,0xffffc
    80206d1a:	e10080e7          	jalr	-496(ra) # 80202b26 <memset>
    if (off <= 32) {   // TODO? 具体见__fat32_alloc
    80206d1e:	f7c42783          	lw	a5,-132(s0)
    80206d22:	0007871b          	sext.w	a4,a5
    80206d26:	02000793          	li	a5,32
    80206d2a:	0ae7e563          	bltu	a5,a4,80206dd4 <__fat32_create+0xfe>
        if (off == 0)  //创建 '.' 项
    80206d2e:	f7c42783          	lw	a5,-132(s0)
    80206d32:	2781                	sext.w	a5,a5
    80206d34:	ef91                	bnez	a5,80206d50 <__fat32_create+0x7a>
            strncpy(fentry.shortNameDir.name, ".", SHORT_NAME_LEN);
    80206d36:	fa840793          	addi	a5,s0,-88
    80206d3a:	462d                	li	a2,11
    80206d3c:	00005597          	auipc	a1,0x5
    80206d40:	92c58593          	addi	a1,a1,-1748 # 8020b668 <illegal+0xa8>
    80206d44:	853e                	mv	a0,a5
    80206d46:	ffffc097          	auipc	ra,0xffffc
    80206d4a:	054080e7          	jalr	84(ra) # 80202d9a <strncpy>
    80206d4e:	a829                	j	80206d68 <__fat32_create+0x92>
        else  // off==32, 创建 '..' 项
            strncpy(fentry.shortNameDir.name, "..", SHORT_NAME_LEN);
    80206d50:	fa840793          	addi	a5,s0,-88
    80206d54:	462d                	li	a2,11
    80206d56:	00005597          	auipc	a1,0x5
    80206d5a:	91a58593          	addi	a1,a1,-1766 # 8020b670 <illegal+0xb0>
    80206d5e:	853e                	mv	a0,a5
    80206d60:	ffffc097          	auipc	ra,0xffffc
    80206d64:	03a080e7          	jalr	58(ra) # 80202d9a <strncpy>
        fentry.shortNameDir.attribute = ATTR_DIRECTORY;  // TODO?
    80206d68:	47c1                	li	a5,16
    80206d6a:	faf409a3          	sb	a5,-77(s0)
        fentry.shortNameDir.start_high = (uint16_t)(entry->firstClus >> 16);
    80206d6e:	f8043783          	ld	a5,-128(s0)
    80206d72:	1307a783          	lw	a5,304(a5)
    80206d76:	0107d79b          	srliw	a5,a5,0x10
    80206d7a:	2781                	sext.w	a5,a5
    80206d7c:	17c2                	slli	a5,a5,0x30
    80206d7e:	93c1                	srli	a5,a5,0x30
    80206d80:	faf41e23          	sh	a5,-68(s0)
        fentry.shortNameDir.start_low = (uint16_t)(entry->firstClus & 0xffff);
    80206d84:	f8043783          	ld	a5,-128(s0)
    80206d88:	1307a783          	lw	a5,304(a5)
    80206d8c:	17c2                	slli	a5,a5,0x30
    80206d8e:	93c1                	srli	a5,a5,0x30
    80206d90:	fcf41123          	sh	a5,-62(s0)
        fentry.shortNameDir.size = 0;  // TODO?
    80206d94:	fc042223          	sw	zero,-60(s0)
        off = clus_locate(dir, off, TRUE);
    80206d98:	f7c42783          	lw	a5,-132(s0)
    80206d9c:	4605                	li	a2,1
    80206d9e:	85be                	mv	a1,a5
    80206da0:	f8843503          	ld	a0,-120(s0)
    80206da4:	ffffe097          	auipc	ra,0xffffe
    80206da8:	6c2080e7          	jalr	1730(ra) # 80205466 <clus_locate>
    80206dac:	87aa                	mv	a5,a0
    80206dae:	f6f42e23          	sw	a5,-132(s0)
        clus_io(dir->curClus, TRUE, 0, (byte_t*)&fentry, off, sizeof(fentry));
    80206db2:	f8843783          	ld	a5,-120(s0)
    80206db6:	1387a503          	lw	a0,312(a5)
    80206dba:	f7c42703          	lw	a4,-132(s0)
    80206dbe:	fa840693          	addi	a3,s0,-88
    80206dc2:	02000793          	li	a5,32
    80206dc6:	4601                	li	a2,0
    80206dc8:	4585                	li	a1,1
    80206dca:	ffffe097          	auipc	ra,0xffffe
    80206dce:	498080e7          	jalr	1176(ra) # 80205262 <clus_io>
    80206dd2:	a40d                	j	80206ff4 <__fat32_create+0x31e>
    } else {  //长文件名
        //计算所需目录项数，并向上取整
        int entCnt = (strlen(entry->d_name) + LONG_NAME_LEN - 1) / LONG_NAME_LEN;
    80206dd4:	f8043783          	ld	a5,-128(s0)
    80206dd8:	07d5                	addi	a5,a5,21
    80206dda:	853e                	mv	a0,a5
    80206ddc:	ffffc097          	auipc	ra,0xffffc
    80206de0:	090080e7          	jalr	144(ra) # 80202e6c <strlen>
    80206de4:	87aa                	mv	a5,a0
    80206de6:	00c78713          	addi	a4,a5,12
    80206dea:	47b5                	li	a5,13
    80206dec:	02f757b3          	divu	a5,a4,a5
    80206df0:	fcf42c23          	sw	a5,-40(s0)
        char shortName[SHORT_NAME_LEN + 1] = {'\0'};
    80206df4:	f8043c23          	sd	zero,-104(s0)
    80206df8:	fa042023          	sw	zero,-96(s0)
        generateShortName(shortName, entry->d_name);  // TODO可行？
    80206dfc:	f8043783          	ld	a5,-128(s0)
    80206e00:	01578713          	addi	a4,a5,21
    80206e04:	f9840793          	addi	a5,s0,-104
    80206e08:	85ba                	mv	a1,a4
    80206e0a:	853e                	mv	a0,a5
    80206e0c:	fffff097          	auipc	ra,0xfffff
    80206e10:	87e080e7          	jalr	-1922(ra) # 8020568a <generateShortName>
        fentry.longNameDir.checksum = calCheckSum((uint8_t*)shortName);
    80206e14:	f9840793          	addi	a5,s0,-104
    80206e18:	853e                	mv	a0,a5
    80206e1a:	fffff097          	auipc	ra,0xfffff
    80206e1e:	b7e080e7          	jalr	-1154(ra) # 80205998 <calCheckSum>
    80206e22:	87aa                	mv	a5,a0
    80206e24:	faf40aa3          	sb	a5,-75(s0)
        fentry.longNameDir.attribute = ATTR_LONG_FILE_NAME;
    80206e28:	47bd                	li	a5,15
    80206e2a:	faf409a3          	sb	a5,-77(s0)
        //倒序排列在目录表中
        for (int i = entCnt; i > 0; --i) {
    80206e2e:	fd842783          	lw	a5,-40(s0)
    80206e32:	fef42623          	sw	a5,-20(s0)
    80206e36:	a21d                	j	80206f5c <__fat32_create+0x286>
            fentry.longNameDir.sequence = i;
    80206e38:	fec42783          	lw	a5,-20(s0)
    80206e3c:	0ff7f793          	zext.b	a5,a5
    80206e40:	faf40423          	sb	a5,-88(s0)
            if (i == entCnt)  // TODO判断条件没错？
    80206e44:	fec42703          	lw	a4,-20(s0)
    80206e48:	fd842783          	lw	a5,-40(s0)
    80206e4c:	2701                	sext.w	a4,a4
    80206e4e:	2781                	sext.w	a5,a5
    80206e50:	00f71a63          	bne	a4,a5,80206e64 <__fat32_create+0x18e>
                fentry.longNameDir.sequence |= LAST_LONG_ENTRY;
    80206e54:	fa844783          	lbu	a5,-88(s0)
    80206e58:	0407e793          	ori	a5,a5,64
    80206e5c:	0ff7f793          	zext.b	a5,a5
    80206e60:	faf40423          	sb	a5,-88(s0)
            char* p = entry->d_name + (i - 1) * LONG_NAME_LEN;
    80206e64:	f8043783          	ld	a5,-128(s0)
    80206e68:	01578693          	addi	a3,a5,21
    80206e6c:	fec42783          	lw	a5,-20(s0)
    80206e70:	37fd                	addiw	a5,a5,-1
    80206e72:	2781                	sext.w	a5,a5
    80206e74:	873e                	mv	a4,a5
    80206e76:	87ba                	mv	a5,a4
    80206e78:	0017979b          	slliw	a5,a5,0x1
    80206e7c:	9fb9                	addw	a5,a5,a4
    80206e7e:	0027979b          	slliw	a5,a5,0x2
    80206e82:	9fb9                	addw	a5,a5,a4
    80206e84:	2781                	sext.w	a5,a5
    80206e86:	97b6                	add	a5,a5,a3
    80206e88:	fcf43823          	sd	a5,-48(s0)
            // file name
            wchar_t* name = fentry.longNameDir.f5Name;
    80206e8c:	fa840793          	addi	a5,s0,-88
    80206e90:	0785                	addi	a5,a5,1
    80206e92:	fef43023          	sd	a5,-32(s0)
            for (int j = 0; j < LONG_NAME_LEN; ++j) {
    80206e96:	fc042e23          	sw	zero,-36(s0)
    80206e9a:	a095                	j	80206efe <__fat32_create+0x228>
                *name = p[j];
    80206e9c:	fdc42783          	lw	a5,-36(s0)
    80206ea0:	fd043703          	ld	a4,-48(s0)
    80206ea4:	97ba                	add	a5,a5,a4
    80206ea6:	0007c783          	lbu	a5,0(a5)
    80206eaa:	03079713          	slli	a4,a5,0x30
    80206eae:	9341                	srli	a4,a4,0x30
    80206eb0:	fe043783          	ld	a5,-32(s0)
    80206eb4:	00e79023          	sh	a4,0(a5)
                ++name;
    80206eb8:	fe043783          	ld	a5,-32(s0)
    80206ebc:	0789                	addi	a5,a5,2
    80206ebe:	fef43023          	sd	a5,-32(s0)
                if (j == 5 - 1)
    80206ec2:	fdc42783          	lw	a5,-36(s0)
    80206ec6:	0007871b          	sext.w	a4,a5
    80206eca:	4791                	li	a5,4
    80206ecc:	00f71863          	bne	a4,a5,80206edc <__fat32_create+0x206>
                    name = fentry.longNameDir.m6Name;
    80206ed0:	fa840793          	addi	a5,s0,-88
    80206ed4:	07b9                	addi	a5,a5,14
    80206ed6:	fef43023          	sd	a5,-32(s0)
    80206eda:	a829                	j	80206ef4 <__fat32_create+0x21e>
                else if (j == 11 - 1)
    80206edc:	fdc42783          	lw	a5,-36(s0)
    80206ee0:	0007871b          	sext.w	a4,a5
    80206ee4:	47a9                	li	a5,10
    80206ee6:	00f71763          	bne	a4,a5,80206ef4 <__fat32_create+0x21e>
                    name = fentry.longNameDir.e2Name;
    80206eea:	fa840793          	addi	a5,s0,-88
    80206eee:	07f1                	addi	a5,a5,28
    80206ef0:	fef43023          	sd	a5,-32(s0)
            for (int j = 0; j < LONG_NAME_LEN; ++j) {
    80206ef4:	fdc42783          	lw	a5,-36(s0)
    80206ef8:	2785                	addiw	a5,a5,1
    80206efa:	fcf42e23          	sw	a5,-36(s0)
    80206efe:	fdc42783          	lw	a5,-36(s0)
    80206f02:	0007871b          	sext.w	a4,a5
    80206f06:	47b1                	li	a5,12
    80206f08:	f8e7dae3          	bge	a5,a4,80206e9c <__fat32_create+0x1c6>
            }
            uint32_t diskOff = clus_locate(dir, off, TRUE);
    80206f0c:	f7c42783          	lw	a5,-132(s0)
    80206f10:	4605                	li	a2,1
    80206f12:	85be                	mv	a1,a5
    80206f14:	f8843503          	ld	a0,-120(s0)
    80206f18:	ffffe097          	auipc	ra,0xffffe
    80206f1c:	54e080e7          	jalr	1358(ra) # 80205466 <clus_locate>
    80206f20:	87aa                	mv	a5,a0
    80206f22:	fcf42623          	sw	a5,-52(s0)
            clus_io(dir->curClus, TRUE, 0, (byte_t*)&fentry, diskOff, sizeof(fentry));
    80206f26:	f8843783          	ld	a5,-120(s0)
    80206f2a:	1387a503          	lw	a0,312(a5)
    80206f2e:	fcc42703          	lw	a4,-52(s0)
    80206f32:	fa840693          	addi	a3,s0,-88
    80206f36:	02000793          	li	a5,32
    80206f3a:	4601                	li	a2,0
    80206f3c:	4585                	li	a1,1
    80206f3e:	ffffe097          	auipc	ra,0xffffe
    80206f42:	324080e7          	jalr	804(ra) # 80205262 <clus_io>
            off += sizeof(fentry);
    80206f46:	f7c42783          	lw	a5,-132(s0)
    80206f4a:	0207879b          	addiw	a5,a5,32
    80206f4e:	f6f42e23          	sw	a5,-132(s0)
        for (int i = entCnt; i > 0; --i) {
    80206f52:	fec42783          	lw	a5,-20(s0)
    80206f56:	37fd                	addiw	a5,a5,-1
    80206f58:	fef42623          	sw	a5,-20(s0)
    80206f5c:	fec42783          	lw	a5,-20(s0)
    80206f60:	2781                	sext.w	a5,a5
    80206f62:	ecf04be3          	bgtz	a5,80206e38 <__fat32_create+0x162>
        }
        strncpy(fentry.shortNameDir.name, shortName, sizeof(fentry.shortNameDir.name));
    80206f66:	f9840713          	addi	a4,s0,-104
    80206f6a:	fa840793          	addi	a5,s0,-88
    80206f6e:	462d                	li	a2,11
    80206f70:	85ba                	mv	a1,a4
    80206f72:	853e                	mv	a0,a5
    80206f74:	ffffc097          	auipc	ra,0xffffc
    80206f78:	e26080e7          	jalr	-474(ra) # 80202d9a <strncpy>
        fentry.shortNameDir.attribute = entry->d_type;
    80206f7c:	f8043783          	ld	a5,-128(s0)
    80206f80:	0147c783          	lbu	a5,20(a5)
    80206f84:	faf409a3          	sb	a5,-77(s0)
        fentry.shortNameDir.start_high = (uint16_t)(entry->firstClus >> 16);
    80206f88:	f8043783          	ld	a5,-128(s0)
    80206f8c:	1307a783          	lw	a5,304(a5)
    80206f90:	0107d79b          	srliw	a5,a5,0x10
    80206f94:	2781                	sext.w	a5,a5
    80206f96:	17c2                	slli	a5,a5,0x30
    80206f98:	93c1                	srli	a5,a5,0x30
    80206f9a:	faf41e23          	sh	a5,-68(s0)
        fentry.shortNameDir.start_low = (uint16_t)(entry->firstClus & 0xffff);
    80206f9e:	f8043783          	ld	a5,-128(s0)
    80206fa2:	1307a783          	lw	a5,304(a5)
    80206fa6:	17c2                	slli	a5,a5,0x30
    80206fa8:	93c1                	srli	a5,a5,0x30
    80206faa:	fcf41123          	sh	a5,-62(s0)
        fentry.shortNameDir.size = entry->size;
    80206fae:	f8043783          	ld	a5,-128(s0)
    80206fb2:	1347a783          	lw	a5,308(a5)
    80206fb6:	fcf42223          	sw	a5,-60(s0)
        off = clus_locate(dir, off, TRUE);
    80206fba:	f7c42783          	lw	a5,-132(s0)
    80206fbe:	4605                	li	a2,1
    80206fc0:	85be                	mv	a1,a5
    80206fc2:	f8843503          	ld	a0,-120(s0)
    80206fc6:	ffffe097          	auipc	ra,0xffffe
    80206fca:	4a0080e7          	jalr	1184(ra) # 80205466 <clus_locate>
    80206fce:	87aa                	mv	a5,a0
    80206fd0:	f6f42e23          	sw	a5,-132(s0)
        clus_io(dir->curClus, TRUE, 0, (byte_t*)&fentry, off, sizeof(fentry));
    80206fd4:	f8843783          	ld	a5,-120(s0)
    80206fd8:	1387a503          	lw	a0,312(a5)
    80206fdc:	f7c42703          	lw	a4,-132(s0)
    80206fe0:	fa840693          	addi	a3,s0,-88
    80206fe4:	02000793          	li	a5,32
    80206fe8:	4601                	li	a2,0
    80206fea:	4585                	li	a1,1
    80206fec:	ffffe097          	auipc	ra,0xffffe
    80206ff0:	276080e7          	jalr	630(ra) # 80205262 <clus_io>
    }
    return 0;
    80206ff4:	4781                	li	a5,0
}
    80206ff6:	853e                	mv	a0,a5
    80206ff8:	60aa                	ld	ra,136(sp)
    80206ffa:	640a                	ld	s0,128(sp)
    80206ffc:	6149                	addi	sp,sp,144
    80206ffe:	8082                	ret

0000000080207000 <__fat32_alloc>:

dirent_t*
__fat32_alloc(dirent_t* dentry, char* name, uint32_t attr) {
    80207000:	7139                	addi	sp,sp,-64
    80207002:	fc06                	sd	ra,56(sp)
    80207004:	f822                	sd	s0,48(sp)
    80207006:	0080                	addi	s0,sp,64
    80207008:	fca43c23          	sd	a0,-40(s0)
    8020700c:	fcb43823          	sd	a1,-48(s0)
    80207010:	87b2                	mv	a5,a2
    80207012:	fcf42623          	sw	a5,-52(s0)
    if (!(dentry->d_type & ATTR_DIRECTORY))
    80207016:	fd843783          	ld	a5,-40(s0)
    8020701a:	0147c783          	lbu	a5,20(a5)
    8020701e:	2781                	sext.w	a5,a5
    80207020:	8bc1                	andi	a5,a5,16
    80207022:	2781                	sext.w	a5,a5
    80207024:	eb89                	bnez	a5,80207036 <__fat32_alloc+0x36>
        panic("not dentry");
    80207026:	00004517          	auipc	a0,0x4
    8020702a:	65250513          	addi	a0,a0,1618 # 8020b678 <illegal+0xb8>
    8020702e:	ffffc097          	auipc	ra,0xffffc
    80207032:	ad6080e7          	jalr	-1322(ra) # 80202b04 <panic>
    name = formatName(name);
    80207036:	fd043503          	ld	a0,-48(s0)
    8020703a:	ffffe097          	auipc	ra,0xffffe
    8020703e:	582080e7          	jalr	1410(ra) # 802055bc <formatName>
    80207042:	fca43823          	sd	a0,-48(s0)
    if (dentry->valid == FALSE || name == NULL)
    80207046:	fd843783          	ld	a5,-40(s0)
    8020704a:	1487a783          	lw	a5,328(a5)
    8020704e:	c781                	beqz	a5,80207056 <__fat32_alloc+0x56>
    80207050:	fd043783          	ld	a5,-48(s0)
    80207054:	e399                	bnez	a5,8020705a <__fat32_alloc+0x5a>
        return NULL;
    80207056:	4781                	li	a5,0
    80207058:	aa9d                	j	802071ce <__fat32_alloc+0x1ce>

    uint32_t off = 0;
    8020705a:	fe042223          	sw	zero,-28(s0)
    dirent_t* entry = __fat32_lookupDir(dentry, name, &off);
    8020705e:	fe440793          	addi	a5,s0,-28
    80207062:	863e                	mv	a2,a5
    80207064:	fd043583          	ld	a1,-48(s0)
    80207068:	fd843503          	ld	a0,-40(s0)
    8020706c:	00000097          	auipc	ra,0x0
    80207070:	8b4080e7          	jalr	-1868(ra) # 80206920 <__fat32_lookupDir>
    80207074:	fea43423          	sd	a0,-24(s0)
    if (entry != NULL)  // entry already exists
    80207078:	fe843783          	ld	a5,-24(s0)
    8020707c:	c781                	beqz	a5,80207084 <__fat32_alloc+0x84>
        return entry;
    8020707e:	fe843783          	ld	a5,-24(s0)
    80207082:	a2b1                	j	802071ce <__fat32_alloc+0x1ce>

    spinlock_acquire(&pathCache.dentry_lk);
    80207084:	0031f517          	auipc	a0,0x31f
    80207088:	78c50513          	addi	a0,a0,1932 # 80526810 <pathCache>
    8020708c:	ffffe097          	auipc	ra,0xffffe
    80207090:	8c6080e7          	jalr	-1850(ra) # 80204952 <spinlock_acquire>
    {
        entry = pathCache_alloc(dentry);
    80207094:	fd843503          	ld	a0,-40(s0)
    80207098:	fffff097          	auipc	ra,0xfffff
    8020709c:	ae2080e7          	jalr	-1310(ra) # 80205b7a <pathCache_alloc>
    802070a0:	fea43423          	sd	a0,-24(s0)
        entry->d_type = attr;
    802070a4:	fcc42783          	lw	a5,-52(s0)
    802070a8:	0ff7f713          	zext.b	a4,a5
    802070ac:	fe843783          	ld	a5,-24(s0)
    802070b0:	00e78a23          	sb	a4,20(a5)
        entry->size = 0;
    802070b4:	fe843783          	ld	a5,-24(s0)
    802070b8:	1207aa23          	sw	zero,308(a5)
        entry->firstClus = 0;
    802070bc:	fe843783          	ld	a5,-24(s0)
    802070c0:	1207a823          	sw	zero,304(a5)
        entry->parent = __fat32_dup(dentry);
    802070c4:	fd843503          	ld	a0,-40(s0)
    802070c8:	fffff097          	auipc	ra,0xfffff
    802070cc:	f1c080e7          	jalr	-228(ra) # 80205fe4 <__fat32_dup>
    802070d0:	872a                	mv	a4,a0
    802070d2:	fe843783          	ld	a5,-24(s0)
    802070d6:	14e7bc23          	sd	a4,344(a5)
        entry->d_off = off;
    802070da:	fe442783          	lw	a5,-28(s0)
    802070de:	02079713          	slli	a4,a5,0x20
    802070e2:	9301                	srli	a4,a4,0x20
    802070e4:	fe843783          	ld	a5,-24(s0)
    802070e8:	e798                	sd	a4,8(a5)
        entry->clusCnt = 0;
    802070ea:	fe843783          	ld	a5,-24(s0)
    802070ee:	1207ae23          	sw	zero,316(a5)
        entry->curClus = 0;
    802070f2:	fe843783          	ld	a5,-24(s0)
    802070f6:	1207ac23          	sw	zero,312(a5)
        strncpy(entry->d_name, name, FAT32_MAX_FILENAME);
    802070fa:	fe843783          	ld	a5,-24(s0)
    802070fe:	07d5                	addi	a5,a5,21
    80207100:	0ff00613          	li	a2,255
    80207104:	fd043583          	ld	a1,-48(s0)
    80207108:	853e                	mv	a0,a5
    8020710a:	ffffc097          	auipc	ra,0xffffc
    8020710e:	c90080e7          	jalr	-880(ra) # 80202d9a <strncpy>
        entry->d_name[FAT32_MAX_FILENAME] = '\0';
    80207112:	fe843783          	ld	a5,-24(s0)
    80207116:	10078a23          	sb	zero,276(a5)
        if (attr == ATTR_DIRECTORY) {
    8020711a:	fcc42783          	lw	a5,-52(s0)
    8020711e:	0007871b          	sext.w	a4,a5
    80207122:	47c1                	li	a5,16
    80207124:	04f71e63          	bne	a4,a5,80207180 <__fat32_alloc+0x180>
            entry->curClus = entry->firstClus = clus_alloc(dentry->dev);
    80207128:	fd843783          	ld	a5,-40(s0)
    8020712c:	1407c783          	lbu	a5,320(a5)
    80207130:	853e                	mv	a0,a5
    80207132:	ffffe097          	auipc	ra,0xffffe
    80207136:	0a0080e7          	jalr	160(ra) # 802051d2 <clus_alloc>
    8020713a:	87aa                	mv	a5,a0
    8020713c:	0007871b          	sext.w	a4,a5
    80207140:	fe843783          	ld	a5,-24(s0)
    80207144:	12e7a823          	sw	a4,304(a5)
    80207148:	fe843783          	ld	a5,-24(s0)
    8020714c:	1307a703          	lw	a4,304(a5)
    80207150:	fe843783          	ld	a5,-24(s0)
    80207154:	12e7ac23          	sw	a4,312(a5)
            __fat32_create(entry, entry, 0);
    80207158:	4601                	li	a2,0
    8020715a:	fe843583          	ld	a1,-24(s0)
    8020715e:	fe843503          	ld	a0,-24(s0)
    80207162:	00000097          	auipc	ra,0x0
    80207166:	b74080e7          	jalr	-1164(ra) # 80206cd6 <__fat32_create>
            __fat32_create(entry, dentry, sizeof(fat32Entry_t));
    8020716a:	02000613          	li	a2,32
    8020716e:	fd843583          	ld	a1,-40(s0)
    80207172:	fe843503          	ld	a0,-24(s0)
    80207176:	00000097          	auipc	ra,0x0
    8020717a:	b60080e7          	jalr	-1184(ra) # 80206cd6 <__fat32_create>
    8020717e:	a829                	j	80207198 <__fat32_alloc+0x198>
        } else
            entry->d_type |= ATTR_ARCHIVE;
    80207180:	fe843783          	ld	a5,-24(s0)
    80207184:	0147c783          	lbu	a5,20(a5)
    80207188:	0207e793          	ori	a5,a5,32
    8020718c:	0ff7f713          	zext.b	a4,a5
    80207190:	fe843783          	ld	a5,-24(s0)
    80207194:	00e78a23          	sb	a4,20(a5)
        __fat32_create(dentry, entry, off);
    80207198:	fe442783          	lw	a5,-28(s0)
    8020719c:	863e                	mv	a2,a5
    8020719e:	fe843583          	ld	a1,-24(s0)
    802071a2:	fd843503          	ld	a0,-40(s0)
    802071a6:	00000097          	auipc	ra,0x0
    802071aa:	b30080e7          	jalr	-1232(ra) # 80206cd6 <__fat32_create>
        entry->valid = TRUE;
    802071ae:	fe843783          	ld	a5,-24(s0)
    802071b2:	4705                	li	a4,1
    802071b4:	14e7a423          	sw	a4,328(a5)
    }
    spinlock_acquire(&entry->d_lk);
    802071b8:	fe843783          	ld	a5,-24(s0)
    802071bc:	11878793          	addi	a5,a5,280
    802071c0:	853e                	mv	a0,a5
    802071c2:	ffffd097          	auipc	ra,0xffffd
    802071c6:	790080e7          	jalr	1936(ra) # 80204952 <spinlock_acquire>
    return entry;
    802071ca:	fe843783          	ld	a5,-24(s0)
}
    802071ce:	853e                	mv	a0,a5
    802071d0:	70e2                	ld	ra,56(sp)
    802071d2:	7442                	ld	s0,48(sp)
    802071d4:	6121                	addi	sp,sp,64
    802071d6:	8082                	ret

00000000802071d8 <__fat32_name>:
 *
 * @param path
 * @return dirent_t*
 */
dirent_t*
__fat32_name(char* path) {
    802071d8:	712d                	addi	sp,sp,-288
    802071da:	ee06                	sd	ra,280(sp)
    802071dc:	ea22                	sd	s0,272(sp)
    802071de:	1200                	addi	s0,sp,288
    802071e0:	eea43423          	sd	a0,-280(s0)
    char name[FAT32_MAX_FILENAME + 1];
    return __fat32_lookupPath(path, 0, name);
    802071e4:	ef040793          	addi	a5,s0,-272
    802071e8:	863e                	mv	a2,a5
    802071ea:	4581                	li	a1,0
    802071ec:	ee843503          	ld	a0,-280(s0)
    802071f0:	00000097          	auipc	ra,0x0
    802071f4:	968080e7          	jalr	-1688(ra) # 80206b58 <__fat32_lookupPath>
    802071f8:	87aa                	mv	a5,a0
}
    802071fa:	853e                	mv	a0,a5
    802071fc:	60f2                	ld	ra,280(sp)
    802071fe:	6452                	ld	s0,272(sp)
    80207200:	6115                	addi	sp,sp,288
    80207202:	8082                	ret

0000000080207204 <__fat32_nameParent>:
 * @param path
 * @param name
 * @return dirent_t*
 */
dirent_t*
__fat32_nameParent(char* path, char* name) {
    80207204:	1101                	addi	sp,sp,-32
    80207206:	ec06                	sd	ra,24(sp)
    80207208:	e822                	sd	s0,16(sp)
    8020720a:	1000                	addi	s0,sp,32
    8020720c:	fea43423          	sd	a0,-24(s0)
    80207210:	feb43023          	sd	a1,-32(s0)
    return __fat32_lookupPath(path, TRUE, name);
    80207214:	fe043603          	ld	a2,-32(s0)
    80207218:	4585                	li	a1,1
    8020721a:	fe843503          	ld	a0,-24(s0)
    8020721e:	00000097          	auipc	ra,0x0
    80207222:	93a080e7          	jalr	-1734(ra) # 80206b58 <__fat32_lookupPath>
    80207226:	87aa                	mv	a5,a0
}
    80207228:	853e                	mv	a0,a5
    8020722a:	60e2                	ld	ra,24(sp)
    8020722c:	6442                	ld	s0,16(sp)
    8020722e:	6105                	addi	sp,sp,32
    80207230:	8082                	ret

0000000080207232 <fat32_init>:
        node->inodeInfo.__fat32_info;
    }
}
*/
void
fat32_init() {
    80207232:	1101                	addi	sp,sp,-32
    80207234:	ec06                	sd	ra,24(sp)
    80207236:	e822                	sd	s0,16(sp)
    80207238:	1000                	addi	s0,sp,32
    __DEBUG_INFO(fat32_init() enter);
    8020723a:	00004517          	auipc	a0,0x4
    8020723e:	44e50513          	addi	a0,a0,1102 # 8020b688 <illegal+0xc8>
    80207242:	ffffb097          	auipc	ra,0xffffb
    80207246:	6b0080e7          	jalr	1712(ra) # 802028f2 <printf>

    // fat32 = &fat32_fs.fs_info.__fat32_info;
    disk_read((uint8_t*)&fat32.bpb, 0);
    8020724a:	4581                	li	a1,0
    8020724c:	00020517          	auipc	a0,0x20
    80207250:	3a450513          	addi	a0,a0,932 # 802275f0 <fat32>
    80207254:	00000097          	auipc	ra,0x0
    80207258:	6c0080e7          	jalr	1728(ra) # 80207914 <disk_read>
    if (strncmp(fat32.bpb.SystemID, "FAT32", 5))
    8020725c:	4615                	li	a2,5
    8020725e:	00004597          	auipc	a1,0x4
    80207262:	44258593          	addi	a1,a1,1090 # 8020b6a0 <illegal+0xe0>
    80207266:	00020517          	auipc	a0,0x20
    8020726a:	3dc50513          	addi	a0,a0,988 # 80227642 <fat32+0x52>
    8020726e:	ffffc097          	auipc	ra,0xffffc
    80207272:	9d2080e7          	jalr	-1582(ra) # 80202c40 <strncmp>
    80207276:	87aa                	mv	a5,a0
    80207278:	cb89                	beqz	a5,8020728a <fat32_init+0x58>
        panic("not FAT32 volume");
    8020727a:	00004517          	auipc	a0,0x4
    8020727e:	42e50513          	addi	a0,a0,1070 # 8020b6a8 <illegal+0xe8>
    80207282:	ffffc097          	auipc	ra,0xffffc
    80207286:	882080e7          	jalr	-1918(ra) # 80202b04 <panic>
    if (fat32.bpb.bytesPerSector != BSIZE)
    8020728a:	00020797          	auipc	a5,0x20
    8020728e:	36678793          	addi	a5,a5,870 # 802275f0 <fat32>
    80207292:	679c                	ld	a5,8(a5)
    80207294:	83e1                	srli	a5,a5,0x18
    80207296:	9bfd                	andi	a5,a5,-1
    80207298:	17c2                	slli	a5,a5,0x30
    8020729a:	93c1                	srli	a5,a5,0x30
    8020729c:	0007871b          	sext.w	a4,a5
    802072a0:	20000793          	li	a5,512
    802072a4:	00f70a63          	beq	a4,a5,802072b8 <fat32_init+0x86>
        panic("fat32.bpb.bytesPerSector!=BSIZE");
    802072a8:	00004517          	auipc	a0,0x4
    802072ac:	41850513          	addi	a0,a0,1048 # 8020b6c0 <illegal+0x100>
    802072b0:	ffffc097          	auipc	ra,0xffffc
    802072b4:	854080e7          	jalr	-1964(ra) # 80202b04 <panic>
    fat32.firstDataSec = fat32.bpb.reservedSectorNum + fat32.bpb.FATNum * fat32.bpb.secPerFAT32;
    802072b8:	00020797          	auipc	a5,0x20
    802072bc:	33878793          	addi	a5,a5,824 # 802275f0 <fat32>
    802072c0:	00e7d783          	lhu	a5,14(a5)
    802072c4:	0007871b          	sext.w	a4,a5
    802072c8:	00020797          	auipc	a5,0x20
    802072cc:	32878793          	addi	a5,a5,808 # 802275f0 <fat32>
    802072d0:	0107c783          	lbu	a5,16(a5)
    802072d4:	0007869b          	sext.w	a3,a5
    802072d8:	00020797          	auipc	a5,0x20
    802072dc:	31878793          	addi	a5,a5,792 # 802275f0 <fat32>
    802072e0:	53dc                	lw	a5,36(a5)
    802072e2:	02f687bb          	mulw	a5,a3,a5
    802072e6:	2781                	sext.w	a5,a5
    802072e8:	9fb9                	addw	a5,a5,a4
    802072ea:	0007871b          	sext.w	a4,a5
    802072ee:	00020797          	auipc	a5,0x20
    802072f2:	30278793          	addi	a5,a5,770 # 802275f0 <fat32>
    802072f6:	20e7a023          	sw	a4,512(a5)
    fat32.dataSecNum = fat32.bpb.totSecs - fat32.firstDataSec;
    802072fa:	00020797          	auipc	a5,0x20
    802072fe:	2f678793          	addi	a5,a5,758 # 802275f0 <fat32>
    80207302:	5398                	lw	a4,32(a5)
    80207304:	00020797          	auipc	a5,0x20
    80207308:	2ec78793          	addi	a5,a5,748 # 802275f0 <fat32>
    8020730c:	2007a783          	lw	a5,512(a5)
    80207310:	40f707bb          	subw	a5,a4,a5
    80207314:	0007871b          	sext.w	a4,a5
    80207318:	00020797          	auipc	a5,0x20
    8020731c:	2d878793          	addi	a5,a5,728 # 802275f0 <fat32>
    80207320:	20e7a223          	sw	a4,516(a5)
    fat32.dataClusNum = fat32.dataSecNum / fat32.bpb.secPerCluster;
    80207324:	00020797          	auipc	a5,0x20
    80207328:	2cc78793          	addi	a5,a5,716 # 802275f0 <fat32>
    8020732c:	2047a703          	lw	a4,516(a5)
    80207330:	00020797          	auipc	a5,0x20
    80207334:	2c078793          	addi	a5,a5,704 # 802275f0 <fat32>
    80207338:	00d7c783          	lbu	a5,13(a5)
    8020733c:	2781                	sext.w	a5,a5
    8020733e:	02f757bb          	divuw	a5,a4,a5
    80207342:	0007871b          	sext.w	a4,a5
    80207346:	00020797          	auipc	a5,0x20
    8020734a:	2aa78793          	addi	a5,a5,682 # 802275f0 <fat32>
    8020734e:	20e7a423          	sw	a4,520(a5)
    fat32.bytePerClus = fat32.bpb.secPerCluster * fat32.bpb.bytesPerSector;
    80207352:	00020797          	auipc	a5,0x20
    80207356:	29e78793          	addi	a5,a5,670 # 802275f0 <fat32>
    8020735a:	00d7c783          	lbu	a5,13(a5)
    8020735e:	0007871b          	sext.w	a4,a5
    80207362:	00020797          	auipc	a5,0x20
    80207366:	28e78793          	addi	a5,a5,654 # 802275f0 <fat32>
    8020736a:	679c                	ld	a5,8(a5)
    8020736c:	83e1                	srli	a5,a5,0x18
    8020736e:	9bfd                	andi	a5,a5,-1
    80207370:	17c2                	slli	a5,a5,0x30
    80207372:	93c1                	srli	a5,a5,0x30
    80207374:	2781                	sext.w	a5,a5
    80207376:	02f707bb          	mulw	a5,a4,a5
    8020737a:	2781                	sext.w	a5,a5
    8020737c:	0007871b          	sext.w	a4,a5
    80207380:	00020797          	auipc	a5,0x20
    80207384:	27078793          	addi	a5,a5,624 # 802275f0 <fat32>
    80207388:	20e7a623          	sw	a4,524(a5)

    // fat32.fatTable = (uint32_t*)kmalloc(fat32.bpb.secPerFAT32 * fat32.bpb.bytesPerSector);
    // fat32.fatTable = (uint32_t*)kmalloc(fat32.dataClusNum * 4);
    fat32.fatEntryPerSec = fat32.bpb.bytesPerSector / sizeof(uint32_t);
    8020738c:	00020797          	auipc	a5,0x20
    80207390:	26478793          	addi	a5,a5,612 # 802275f0 <fat32>
    80207394:	679c                	ld	a5,8(a5)
    80207396:	83e1                	srli	a5,a5,0x18
    80207398:	9bfd                	andi	a5,a5,-1
    8020739a:	17c2                	slli	a5,a5,0x30
    8020739c:	93c1                	srli	a5,a5,0x30
    8020739e:	0027d79b          	srliw	a5,a5,0x2
    802073a2:	17c2                	slli	a5,a5,0x30
    802073a4:	93c1                	srli	a5,a5,0x30
    802073a6:	0007871b          	sext.w	a4,a5
    802073aa:	00020797          	auipc	a5,0x20
    802073ae:	24678793          	addi	a5,a5,582 # 802275f0 <fat32>
    802073b2:	20e7a823          	sw	a4,528(a5)
    for (int i = 0; i < fat32.bpb.secPerFAT32; ++i)
    802073b6:	fe042623          	sw	zero,-20(s0)
    802073ba:	a8a9                	j	80207414 <fat32_init+0x1e2>
        disk_read((uint8_t*)(fat32.fatTable + i * fat32.fatEntryPerSec), i + fat32.bpb.reservedSectorNum);  // TODO此处似乎有可能遇到锁已获取的情况？
    802073bc:	00020797          	auipc	a5,0x20
    802073c0:	23478793          	addi	a5,a5,564 # 802275f0 <fat32>
    802073c4:	2107a703          	lw	a4,528(a5)
    802073c8:	fec42783          	lw	a5,-20(s0)
    802073cc:	02f707bb          	mulw	a5,a4,a5
    802073d0:	2781                	sext.w	a5,a5
    802073d2:	1782                	slli	a5,a5,0x20
    802073d4:	9381                	srli	a5,a5,0x20
    802073d6:	00279713          	slli	a4,a5,0x2
    802073da:	00020797          	auipc	a5,0x20
    802073de:	42a78793          	addi	a5,a5,1066 # 80227804 <fat32+0x214>
    802073e2:	00f706b3          	add	a3,a4,a5
    802073e6:	00020797          	auipc	a5,0x20
    802073ea:	20a78793          	addi	a5,a5,522 # 802275f0 <fat32>
    802073ee:	00e7d783          	lhu	a5,14(a5)
    802073f2:	2781                	sext.w	a5,a5
    802073f4:	fec42703          	lw	a4,-20(s0)
    802073f8:	9fb9                	addw	a5,a5,a4
    802073fa:	2781                	sext.w	a5,a5
    802073fc:	2781                	sext.w	a5,a5
    802073fe:	85be                	mv	a1,a5
    80207400:	8536                	mv	a0,a3
    80207402:	00000097          	auipc	ra,0x0
    80207406:	512080e7          	jalr	1298(ra) # 80207914 <disk_read>
    for (int i = 0; i < fat32.bpb.secPerFAT32; ++i)
    8020740a:	fec42783          	lw	a5,-20(s0)
    8020740e:	2785                	addiw	a5,a5,1
    80207410:	fef42623          	sw	a5,-20(s0)
    80207414:	00020797          	auipc	a5,0x20
    80207418:	1dc78793          	addi	a5,a5,476 # 802275f0 <fat32>
    8020741c:	53d8                	lw	a4,36(a5)
    8020741e:	fec42783          	lw	a5,-20(s0)
    80207422:	f8e7ede3          	bltu	a5,a4,802073bc <fat32_init+0x18a>

    spinlock_init(&pathCache.dentry_lk, "pathCache_lk");
    80207426:	00004597          	auipc	a1,0x4
    8020742a:	2ba58593          	addi	a1,a1,698 # 8020b6e0 <illegal+0x120>
    8020742e:	0031f517          	auipc	a0,0x31f
    80207432:	3e250513          	addi	a0,a0,994 # 80526810 <pathCache>
    80207436:	ffffd097          	auipc	ra,0xffffd
    8020743a:	4ec080e7          	jalr	1260(ra) # 80204922 <spinlock_init>

    spinlock_init(&root.d_lk, "root_lk");
    8020743e:	00004597          	auipc	a1,0x4
    80207442:	2b258593          	addi	a1,a1,690 # 8020b6f0 <illegal+0x130>
    80207446:	00324517          	auipc	a0,0x324
    8020744a:	cda50513          	addi	a0,a0,-806 # 8052b120 <root+0x118>
    8020744e:	ffffd097          	auipc	ra,0xffffd
    80207452:	4d4080e7          	jalr	1236(ra) # 80204922 <spinlock_init>
    root.d_type = ATTR_DIRECTORY | ATTR_SYSTEM;
    80207456:	00324797          	auipc	a5,0x324
    8020745a:	bb278793          	addi	a5,a5,-1102 # 8052b008 <root>
    8020745e:	4751                	li	a4,20
    80207460:	00e78a23          	sb	a4,20(a5)
    root.firstClus = root.curClus = fat32.bpb.rootClusterNo;
    80207464:	00020797          	auipc	a5,0x20
    80207468:	18c78793          	addi	a5,a5,396 # 802275f0 <fat32>
    8020746c:	57d8                	lw	a4,44(a5)
    8020746e:	00324797          	auipc	a5,0x324
    80207472:	b9a78793          	addi	a5,a5,-1126 # 8052b008 <root>
    80207476:	12e7ac23          	sw	a4,312(a5)
    8020747a:	00324797          	auipc	a5,0x324
    8020747e:	b8e78793          	addi	a5,a5,-1138 # 8052b008 <root>
    80207482:	1387a703          	lw	a4,312(a5)
    80207486:	00324797          	auipc	a5,0x324
    8020748a:	b8278793          	addi	a5,a5,-1150 # 8052b008 <root>
    8020748e:	12e7a823          	sw	a4,304(a5)
    root.valid = TRUE;
    80207492:	00324797          	auipc	a5,0x324
    80207496:	b7678793          	addi	a5,a5,-1162 # 8052b008 <root>
    8020749a:	4705                	li	a4,1
    8020749c:	14e7a423          	sw	a4,328(a5)
    root.dev = 0;
    802074a0:	00324797          	auipc	a5,0x324
    802074a4:	b6878793          	addi	a5,a5,-1176 # 8052b008 <root>
    802074a8:	14078023          	sb	zero,320(a5)
    root.prev = root.next = &root;
    802074ac:	00324797          	auipc	a5,0x324
    802074b0:	b5c78793          	addi	a5,a5,-1188 # 8052b008 <root>
    802074b4:	00324717          	auipc	a4,0x324
    802074b8:	b5470713          	addi	a4,a4,-1196 # 8052b008 <root>
    802074bc:	16e7b023          	sd	a4,352(a5)
    802074c0:	00324797          	auipc	a5,0x324
    802074c4:	b4878793          	addi	a5,a5,-1208 # 8052b008 <root>
    802074c8:	1607b703          	ld	a4,352(a5)
    802074cc:	00324797          	auipc	a5,0x324
    802074d0:	b3c78793          	addi	a5,a5,-1220 # 8052b008 <root>
    802074d4:	16e7b423          	sd	a4,360(a5)
    strncpy(root.d_name, "/", FS_MAX_FNAME_LEN);
    802074d8:	0ff00613          	li	a2,255
    802074dc:	00004597          	auipc	a1,0x4
    802074e0:	21c58593          	addi	a1,a1,540 # 8020b6f8 <illegal+0x138>
    802074e4:	00324517          	auipc	a0,0x324
    802074e8:	b3950513          	addi	a0,a0,-1223 # 8052b01d <root+0x15>
    802074ec:	ffffc097          	auipc	ra,0xffffc
    802074f0:	8ae080e7          	jalr	-1874(ra) # 80202d9a <strncpy>
    for (int i = 0; i < ENTRY_CACHE_NUM; ++i) {
    802074f4:	fe042423          	sw	zero,-24(s0)
    802074f8:	a291                	j	8020763c <fat32_init+0x40a>
        pathCache.dentries[i].dev = 0;
    802074fa:	0031f717          	auipc	a4,0x31f
    802074fe:	31670713          	addi	a4,a4,790 # 80526810 <pathCache>
    80207502:	fe842683          	lw	a3,-24(s0)
    80207506:	17000793          	li	a5,368
    8020750a:	02f687b3          	mul	a5,a3,a5
    8020750e:	97ba                	add	a5,a5,a4
    80207510:	14078c23          	sb	zero,344(a5)
        pathCache.dentries[i].valid = FALSE;
    80207514:	0031f717          	auipc	a4,0x31f
    80207518:	2fc70713          	addi	a4,a4,764 # 80526810 <pathCache>
    8020751c:	fe842683          	lw	a3,-24(s0)
    80207520:	17000793          	li	a5,368
    80207524:	02f687b3          	mul	a5,a3,a5
    80207528:	97ba                	add	a5,a5,a4
    8020752a:	1607a023          	sw	zero,352(a5)
        pathCache.dentries[i].ref = 0;
    8020752e:	0031f717          	auipc	a4,0x31f
    80207532:	2e270713          	addi	a4,a4,738 # 80526810 <pathCache>
    80207536:	fe842683          	lw	a3,-24(s0)
    8020753a:	17000793          	li	a5,368
    8020753e:	02f687b3          	mul	a5,a3,a5
    80207542:	97ba                	add	a5,a5,a4
    80207544:	1607a223          	sw	zero,356(a5)
        pathCache.dentries[i].parent = NULL;
    80207548:	0031f717          	auipc	a4,0x31f
    8020754c:	2c870713          	addi	a4,a4,712 # 80526810 <pathCache>
    80207550:	fe842683          	lw	a3,-24(s0)
    80207554:	17000793          	li	a5,368
    80207558:	02f687b3          	mul	a5,a3,a5
    8020755c:	97ba                	add	a5,a5,a4
    8020755e:	1607b823          	sd	zero,368(a5)
        pathCache.dentries[i].next = root.next;
    80207562:	00324797          	auipc	a5,0x324
    80207566:	aa678793          	addi	a5,a5,-1370 # 8052b008 <root>
    8020756a:	1607b703          	ld	a4,352(a5)
    8020756e:	0031f697          	auipc	a3,0x31f
    80207572:	2a268693          	addi	a3,a3,674 # 80526810 <pathCache>
    80207576:	fe842783          	lw	a5,-24(s0)
    8020757a:	00178613          	addi	a2,a5,1
    8020757e:	17000793          	li	a5,368
    80207582:	02f607b3          	mul	a5,a2,a5
    80207586:	97b6                	add	a5,a5,a3
    80207588:	e798                	sd	a4,8(a5)
        pathCache.dentries[i].prev = &root;
    8020758a:	0031f717          	auipc	a4,0x31f
    8020758e:	28670713          	addi	a4,a4,646 # 80526810 <pathCache>
    80207592:	fe842783          	lw	a5,-24(s0)
    80207596:	00178693          	addi	a3,a5,1
    8020759a:	17000793          	li	a5,368
    8020759e:	02f687b3          	mul	a5,a3,a5
    802075a2:	97ba                	add	a5,a5,a4
    802075a4:	00324717          	auipc	a4,0x324
    802075a8:	a6470713          	addi	a4,a4,-1436 # 8052b008 <root>
    802075ac:	eb98                	sd	a4,16(a5)
        spinlock_init(&pathCache.dentries[i].d_lk, "dentry");
    802075ae:	fe842703          	lw	a4,-24(s0)
    802075b2:	17000793          	li	a5,368
    802075b6:	02f707b3          	mul	a5,a4,a5
    802075ba:	12078713          	addi	a4,a5,288
    802075be:	0031f797          	auipc	a5,0x31f
    802075c2:	25278793          	addi	a5,a5,594 # 80526810 <pathCache>
    802075c6:	97ba                	add	a5,a5,a4
    802075c8:	07c1                	addi	a5,a5,16
    802075ca:	00004597          	auipc	a1,0x4
    802075ce:	13658593          	addi	a1,a1,310 # 8020b700 <illegal+0x140>
    802075d2:	853e                	mv	a0,a5
    802075d4:	ffffd097          	auipc	ra,0xffffd
    802075d8:	34e080e7          	jalr	846(ra) # 80204922 <spinlock_init>

        root.next->prev = &pathCache.dentries[i];
    802075dc:	00324797          	auipc	a5,0x324
    802075e0:	a2c78793          	addi	a5,a5,-1492 # 8052b008 <root>
    802075e4:	1607b783          	ld	a5,352(a5)
    802075e8:	fe842683          	lw	a3,-24(s0)
    802075ec:	17000713          	li	a4,368
    802075f0:	02e68733          	mul	a4,a3,a4
    802075f4:	01070693          	addi	a3,a4,16
    802075f8:	0031f717          	auipc	a4,0x31f
    802075fc:	21870713          	addi	a4,a4,536 # 80526810 <pathCache>
    80207600:	9736                	add	a4,a4,a3
    80207602:	0721                	addi	a4,a4,8
    80207604:	16e7b423          	sd	a4,360(a5)
        root.next = &pathCache.dentries[i];
    80207608:	fe842703          	lw	a4,-24(s0)
    8020760c:	17000793          	li	a5,368
    80207610:	02f707b3          	mul	a5,a4,a5
    80207614:	01078713          	addi	a4,a5,16
    80207618:	0031f797          	auipc	a5,0x31f
    8020761c:	1f878793          	addi	a5,a5,504 # 80526810 <pathCache>
    80207620:	97ba                	add	a5,a5,a4
    80207622:	00878713          	addi	a4,a5,8
    80207626:	00324797          	auipc	a5,0x324
    8020762a:	9e278793          	addi	a5,a5,-1566 # 8052b008 <root>
    8020762e:	16e7b023          	sd	a4,352(a5)
    for (int i = 0; i < ENTRY_CACHE_NUM; ++i) {
    80207632:	fe842783          	lw	a5,-24(s0)
    80207636:	2785                	addiw	a5,a5,1
    80207638:	fef42423          	sw	a5,-24(s0)
    8020763c:	fe842783          	lw	a5,-24(s0)
    80207640:	0007871b          	sext.w	a4,a5
    80207644:	03100793          	li	a5,49
    80207648:	eae7d9e3          	bge	a5,a4,802074fa <fat32_init+0x2c8>
    }
    // elf_load(getCurrentProc(), "getpid");
    __DEBUG_INFO(fat32_init() over);
    8020764c:	00004517          	auipc	a0,0x4
    80207650:	0bc50513          	addi	a0,a0,188 # 8020b708 <illegal+0x148>
    80207654:	ffffb097          	auipc	ra,0xffffb
    80207658:	29e080e7          	jalr	670(ra) # 802028f2 <printf>
    8020765c:	0001                	nop
    8020765e:	60e2                	ld	ra,24(sp)
    80207660:	6442                	ld	s0,16(sp)
    80207662:	6105                	addi	sp,sp,32
    80207664:	8082                	ret

0000000080207666 <file_init>:
//         file_lock_init(&fd_array[i]);
//     }
// }

void
file_init() {
    80207666:	1101                	addi	sp,sp,-32
    80207668:	ec06                	sd	ra,24(sp)
    8020766a:	e822                	sd	s0,16(sp)
    8020766c:	1000                	addi	s0,sp,32
    spinlock_init(&f_table.ft_lk, "f_table_lk");
    8020766e:	00004597          	auipc	a1,0x4
    80207672:	0b258593          	addi	a1,a1,178 # 8020b720 <illegal+0x160>
    80207676:	00324517          	auipc	a0,0x324
    8020767a:	b0250513          	addi	a0,a0,-1278 # 8052b178 <f_table>
    8020767e:	ffffd097          	auipc	ra,0xffffd
    80207682:	2a4080e7          	jalr	676(ra) # 80204922 <spinlock_init>
    for (int i = 0; i < MAX_FILE_NUM; ++i)
    80207686:	fe042623          	sw	zero,-20(s0)
    8020768a:	a825                	j	802076c2 <file_init+0x5c>
        memset(&f_table.file[i], 0, sizeof(file_t));
    8020768c:	fec42703          	lw	a4,-20(s0)
    80207690:	87ba                	mv	a5,a4
    80207692:	078a                	slli	a5,a5,0x2
    80207694:	97ba                	add	a5,a5,a4
    80207696:	0792                	slli	a5,a5,0x4
    80207698:	01078713          	addi	a4,a5,16
    8020769c:	00324797          	auipc	a5,0x324
    802076a0:	adc78793          	addi	a5,a5,-1316 # 8052b178 <f_table>
    802076a4:	97ba                	add	a5,a5,a4
    802076a6:	07a1                	addi	a5,a5,8
    802076a8:	05000613          	li	a2,80
    802076ac:	4581                	li	a1,0
    802076ae:	853e                	mv	a0,a5
    802076b0:	ffffb097          	auipc	ra,0xffffb
    802076b4:	476080e7          	jalr	1142(ra) # 80202b26 <memset>
    for (int i = 0; i < MAX_FILE_NUM; ++i)
    802076b8:	fec42783          	lw	a5,-20(s0)
    802076bc:	2785                	addiw	a5,a5,1
    802076be:	fef42623          	sw	a5,-20(s0)
    802076c2:	fec42783          	lw	a5,-20(s0)
    802076c6:	0007871b          	sext.w	a4,a5
    802076ca:	06300793          	li	a5,99
    802076ce:	fae7dfe3          	bge	a5,a4,8020768c <file_init+0x26>
    __DEBUG_INFO(file_init());
    802076d2:	00004517          	auipc	a0,0x4
    802076d6:	05e50513          	addi	a0,a0,94 # 8020b730 <illegal+0x170>
    802076da:	ffffb097          	auipc	ra,0xffffb
    802076de:	218080e7          	jalr	536(ra) # 802028f2 <printf>
}
    802076e2:	0001                	nop
    802076e4:	60e2                	ld	ra,24(sp)
    802076e6:	6442                	ld	s0,16(sp)
    802076e8:	6105                	addi	sp,sp,32
    802076ea:	8082                	ret

00000000802076ec <__fd_alloc>:

int
__fd_alloc(file_t* f) {
    802076ec:	7179                	addi	sp,sp,-48
    802076ee:	f406                	sd	ra,40(sp)
    802076f0:	f022                	sd	s0,32(sp)
    802076f2:	1800                	addi	s0,sp,48
    802076f4:	fca43c23          	sd	a0,-40(s0)
    int fd;
    for (fd = 0; fd < N_OPEN_FILE; ++fd)
    802076f8:	fe042623          	sw	zero,-20(s0)
    802076fc:	a091                	j	80207740 <__fd_alloc+0x54>
        if (getCurrentProc()->openFiles[fd] == NULL) {
    802076fe:	ffffa097          	auipc	ra,0xffffa
    80207702:	4d0080e7          	jalr	1232(ra) # 80201bce <getCurrentProc>
    80207706:	872a                	mv	a4,a0
    80207708:	fec42783          	lw	a5,-20(s0)
    8020770c:	07d9                	addi	a5,a5,22
    8020770e:	078e                	slli	a5,a5,0x3
    80207710:	97ba                	add	a5,a5,a4
    80207712:	679c                	ld	a5,8(a5)
    80207714:	e38d                	bnez	a5,80207736 <__fd_alloc+0x4a>
            getCurrentProc()->openFiles[fd] = f;
    80207716:	ffffa097          	auipc	ra,0xffffa
    8020771a:	4b8080e7          	jalr	1208(ra) # 80201bce <getCurrentProc>
    8020771e:	872a                	mv	a4,a0
    80207720:	fec42783          	lw	a5,-20(s0)
    80207724:	07d9                	addi	a5,a5,22
    80207726:	078e                	slli	a5,a5,0x3
    80207728:	97ba                	add	a5,a5,a4
    8020772a:	fd843703          	ld	a4,-40(s0)
    8020772e:	e798                	sd	a4,8(a5)
            return fd;
    80207730:	fec42783          	lw	a5,-20(s0)
    80207734:	a839                	j	80207752 <__fd_alloc+0x66>
    for (fd = 0; fd < N_OPEN_FILE; ++fd)
    80207736:	fec42783          	lw	a5,-20(s0)
    8020773a:	2785                	addiw	a5,a5,1
    8020773c:	fef42623          	sw	a5,-20(s0)
    80207740:	fec42783          	lw	a5,-20(s0)
    80207744:	0007871b          	sext.w	a4,a5
    80207748:	09500793          	li	a5,149
    8020774c:	fae7d9e3          	bge	a5,a4,802076fe <__fd_alloc+0x12>
        }
    return -1;  // TODO
    80207750:	57fd                	li	a5,-1
}
    80207752:	853e                	mv	a0,a5
    80207754:	70a2                	ld	ra,40(sp)
    80207756:	7402                	ld	s0,32(sp)
    80207758:	6145                	addi	sp,sp,48
    8020775a:	8082                	ret

000000008020775c <__file_alloc>:

file_t*
__file_alloc() {
    8020775c:	1101                	addi	sp,sp,-32
    8020775e:	ec06                	sd	ra,24(sp)
    80207760:	e822                	sd	s0,16(sp)
    80207762:	1000                	addi	s0,sp,32
    spinlock_acquire(&f_table.ft_lk);
    80207764:	00324517          	auipc	a0,0x324
    80207768:	a1450513          	addi	a0,a0,-1516 # 8052b178 <f_table>
    8020776c:	ffffd097          	auipc	ra,0xffffd
    80207770:	1e6080e7          	jalr	486(ra) # 80204952 <spinlock_acquire>
    for (int i = 0; i < MAX_FILE_NUM; ++i)
    80207774:	fe042623          	sw	zero,-20(s0)
    80207778:	a0bd                	j	802077e6 <__file_alloc+0x8a>
        if (f_table.file[i].openCount == 0) {
    8020777a:	00324697          	auipc	a3,0x324
    8020777e:	9fe68693          	addi	a3,a3,-1538 # 8052b178 <f_table>
    80207782:	fec42703          	lw	a4,-20(s0)
    80207786:	87ba                	mv	a5,a4
    80207788:	078a                	slli	a5,a5,0x2
    8020778a:	97ba                	add	a5,a5,a4
    8020778c:	0792                	slli	a5,a5,0x4
    8020778e:	97b6                	add	a5,a5,a3
    80207790:	47bc                	lw	a5,72(a5)
    80207792:	e7a9                	bnez	a5,802077dc <__file_alloc+0x80>
            f_table.file[i].openCount = 1;
    80207794:	00324697          	auipc	a3,0x324
    80207798:	9e468693          	addi	a3,a3,-1564 # 8052b178 <f_table>
    8020779c:	fec42703          	lw	a4,-20(s0)
    802077a0:	87ba                	mv	a5,a4
    802077a2:	078a                	slli	a5,a5,0x2
    802077a4:	97ba                	add	a5,a5,a4
    802077a6:	0792                	slli	a5,a5,0x4
    802077a8:	97b6                	add	a5,a5,a3
    802077aa:	4705                	li	a4,1
    802077ac:	c7b8                	sw	a4,72(a5)
            spinlock_release(&f_table.ft_lk);
    802077ae:	00324517          	auipc	a0,0x324
    802077b2:	9ca50513          	addi	a0,a0,-1590 # 8052b178 <f_table>
    802077b6:	ffffd097          	auipc	ra,0xffffd
    802077ba:	212080e7          	jalr	530(ra) # 802049c8 <spinlock_release>
            return &f_table.file[i];
    802077be:	fec42703          	lw	a4,-20(s0)
    802077c2:	87ba                	mv	a5,a4
    802077c4:	078a                	slli	a5,a5,0x2
    802077c6:	97ba                	add	a5,a5,a4
    802077c8:	0792                	slli	a5,a5,0x4
    802077ca:	01078713          	addi	a4,a5,16
    802077ce:	00324797          	auipc	a5,0x324
    802077d2:	9aa78793          	addi	a5,a5,-1622 # 8052b178 <f_table>
    802077d6:	97ba                	add	a5,a5,a4
    802077d8:	07a1                	addi	a5,a5,8
    802077da:	a03d                	j	80207808 <__file_alloc+0xac>
    for (int i = 0; i < MAX_FILE_NUM; ++i)
    802077dc:	fec42783          	lw	a5,-20(s0)
    802077e0:	2785                	addiw	a5,a5,1
    802077e2:	fef42623          	sw	a5,-20(s0)
    802077e6:	fec42783          	lw	a5,-20(s0)
    802077ea:	0007871b          	sext.w	a4,a5
    802077ee:	06300793          	li	a5,99
    802077f2:	f8e7d4e3          	bge	a5,a4,8020777a <__file_alloc+0x1e>
        }
    spinlock_release(&f_table.ft_lk);
    802077f6:	00324517          	auipc	a0,0x324
    802077fa:	98250513          	addi	a0,a0,-1662 # 8052b178 <f_table>
    802077fe:	ffffd097          	auipc	ra,0xffffd
    80207802:	1ca080e7          	jalr	458(ra) # 802049c8 <spinlock_release>
    return NULL;
    80207806:	4781                	li	a5,0
}
    80207808:	853e                	mv	a0,a5
    8020780a:	60e2                	ld	ra,24(sp)
    8020780c:	6442                	ld	s0,16(sp)
    8020780e:	6105                	addi	sp,sp,32
    80207810:	8082                	ret

0000000080207812 <fd2file>:
//     to->node = node;
//     fd_array_open(to);
// }

int
fd2file(int fd, file_t** file_store) {
    80207812:	7179                	addi	sp,sp,-48
    80207814:	f406                	sd	ra,40(sp)
    80207816:	f022                	sd	s0,32(sp)
    80207818:	1800                	addi	s0,sp,48
    8020781a:	87aa                	mv	a5,a0
    8020781c:	fcb43823          	sd	a1,-48(s0)
    80207820:	fcf42e23          	sw	a5,-36(s0)
    if (fd >= 0 && fd < FILES_STRUCT_NENTRY) {
    80207824:	fdc42783          	lw	a5,-36(s0)
    80207828:	2781                	sext.w	a5,a5
    8020782a:	0407cc63          	bltz	a5,80207882 <fd2file+0x70>
    8020782e:	fdc42783          	lw	a5,-36(s0)
    80207832:	873e                	mv	a4,a5
    80207834:	03100793          	li	a5,49
    80207838:	04e7e563          	bltu	a5,a4,80207882 <fd2file+0x70>
        file_t* file = getCurrentProc()->openFiles[fd];
    8020783c:	ffffa097          	auipc	ra,0xffffa
    80207840:	392080e7          	jalr	914(ra) # 80201bce <getCurrentProc>
    80207844:	872a                	mv	a4,a0
    80207846:	fdc42783          	lw	a5,-36(s0)
    8020784a:	07d9                	addi	a5,a5,22
    8020784c:	078e                	slli	a5,a5,0x3
    8020784e:	97ba                	add	a5,a5,a4
    80207850:	679c                	ld	a5,8(a5)
    80207852:	fef43423          	sd	a5,-24(s0)
        if (file->status == FD_OPENED && file->fd == fd) {
    80207856:	fe843783          	ld	a5,-24(s0)
    8020785a:	439c                	lw	a5,0(a5)
    8020785c:	873e                	mv	a4,a5
    8020785e:	4785                	li	a5,1
    80207860:	02f71163          	bne	a4,a5,80207882 <fd2file+0x70>
    80207864:	fe843783          	ld	a5,-24(s0)
    80207868:	4b98                	lw	a4,16(a5)
    8020786a:	fdc42783          	lw	a5,-36(s0)
    8020786e:	2781                	sext.w	a5,a5
    80207870:	00e79963          	bne	a5,a4,80207882 <fd2file+0x70>
            *file_store = file;
    80207874:	fd043783          	ld	a5,-48(s0)
    80207878:	fe843703          	ld	a4,-24(s0)
    8020787c:	e398                	sd	a4,0(a5)
            return 0;
    8020787e:	4781                	li	a5,0
    80207880:	a011                	j	80207884 <fd2file+0x72>
        }
    }
    return -E_INVAL;
    80207882:	57f5                	li	a5,-3
}
    80207884:	853e                	mv	a0,a5
    80207886:	70a2                	ld	ra,40(sp)
    80207888:	7402                	ld	s0,32(sp)
    8020788a:	6145                	addi	sp,sp,48
    8020788c:	8082                	ret

000000008020788e <__file_close>:
//     fd_array_close(file);
//     return 0;
// }

int
__file_close(file_t* f) {
    8020788e:	1101                	addi	sp,sp,-32
    80207890:	ec06                	sd	ra,24(sp)
    80207892:	e822                	sd	s0,16(sp)
    80207894:	1000                	addi	s0,sp,32
    80207896:	fea43423          	sd	a0,-24(s0)
    if (f == NULL)
    8020789a:	fe843783          	ld	a5,-24(s0)
    8020789e:	e399                	bnez	a5,802078a4 <__file_close+0x16>
        return -E_INVAL;
    802078a0:	57f5                	li	a5,-3
    802078a2:	a0b9                	j	802078f0 <__file_close+0x62>
    spinlock_acquire(&f_table.ft_lk);
    802078a4:	00324517          	auipc	a0,0x324
    802078a8:	8d450513          	addi	a0,a0,-1836 # 8052b178 <f_table>
    802078ac:	ffffd097          	auipc	ra,0xffffd
    802078b0:	0a6080e7          	jalr	166(ra) # 80204952 <spinlock_acquire>
    if (f->openCount < 1)
    802078b4:	fe843783          	ld	a5,-24(s0)
    802078b8:	5b9c                	lw	a5,48(a5)
    802078ba:	eb89                	bnez	a5,802078cc <__file_close+0x3e>
        panic("__file_close: on process open this file");
    802078bc:	00004517          	auipc	a0,0x4
    802078c0:	e8450513          	addi	a0,a0,-380 # 8020b740 <illegal+0x180>
    802078c4:	ffffb097          	auipc	ra,0xffffb
    802078c8:	240080e7          	jalr	576(ra) # 80202b04 <panic>
    --f->openCount;
    802078cc:	fe843783          	ld	a5,-24(s0)
    802078d0:	5b9c                	lw	a5,48(a5)
    802078d2:	37fd                	addiw	a5,a5,-1
    802078d4:	0007871b          	sext.w	a4,a5
    802078d8:	fe843783          	ld	a5,-24(s0)
    802078dc:	db98                	sw	a4,48(a5)
    spinlock_release(&f_table.ft_lk);
    802078de:	00324517          	auipc	a0,0x324
    802078e2:	89a50513          	addi	a0,a0,-1894 # 8052b178 <f_table>
    802078e6:	ffffd097          	auipc	ra,0xffffd
    802078ea:	0e2080e7          	jalr	226(ra) # 802049c8 <spinlock_release>
    return 0;  // TODO
    802078ee:	4781                	li	a5,0
}
    802078f0:	853e                	mv	a0,a5
    802078f2:	60e2                	ld	ra,24(sp)
    802078f4:	6442                	ld	s0,16(sp)
    802078f6:	6105                	addi	sp,sp,32
    802078f8:	8082                	ret

00000000802078fa <disk_init>:
#else

#include "fs/virtio.h"

void
disk_init(void) {
    802078fa:	1141                	addi	sp,sp,-16
    802078fc:	e406                	sd	ra,8(sp)
    802078fe:	e022                	sd	s0,0(sp)
    80207900:	0800                	addi	s0,sp,16
    virtio_disk_init();
    80207902:	00001097          	auipc	ra,0x1
    80207906:	046080e7          	jalr	70(ra) # 80208948 <virtio_disk_init>
}
    8020790a:	0001                	nop
    8020790c:	60a2                	ld	ra,8(sp)
    8020790e:	6402                	ld	s0,0(sp)
    80207910:	0141                	addi	sp,sp,16
    80207912:	8082                	ret

0000000080207914 <disk_read>:

void
disk_read(uint8_t* buf, uint32_t secNo) {
    80207914:	1101                	addi	sp,sp,-32
    80207916:	ec06                	sd	ra,24(sp)
    80207918:	e822                	sd	s0,16(sp)
    8020791a:	1000                	addi	s0,sp,32
    8020791c:	fea43423          	sd	a0,-24(s0)
    80207920:	87ae                	mv	a5,a1
    80207922:	fef42223          	sw	a5,-28(s0)
    virtio_disk_rw(buf, secNo, 0);
    80207926:	fe442783          	lw	a5,-28(s0)
    8020792a:	4601                	li	a2,0
    8020792c:	85be                	mv	a1,a5
    8020792e:	fe843503          	ld	a0,-24(s0)
    80207932:	00001097          	auipc	ra,0x1
    80207936:	4f4080e7          	jalr	1268(ra) # 80208e26 <virtio_disk_rw>
}
    8020793a:	0001                	nop
    8020793c:	60e2                	ld	ra,24(sp)
    8020793e:	6442                	ld	s0,16(sp)
    80207940:	6105                	addi	sp,sp,32
    80207942:	8082                	ret

0000000080207944 <disk_write>:

void
disk_write(uint8_t* buf, uint32_t secNo) {
    80207944:	1101                	addi	sp,sp,-32
    80207946:	ec06                	sd	ra,24(sp)
    80207948:	e822                	sd	s0,16(sp)
    8020794a:	1000                	addi	s0,sp,32
    8020794c:	fea43423          	sd	a0,-24(s0)
    80207950:	87ae                	mv	a5,a1
    80207952:	fef42223          	sw	a5,-28(s0)
    virtio_disk_rw(buf, secNo, 1);
    80207956:	fe442783          	lw	a5,-28(s0)
    8020795a:	4605                	li	a2,1
    8020795c:	85be                	mv	a1,a5
    8020795e:	fe843503          	ld	a0,-24(s0)
    80207962:	00001097          	auipc	ra,0x1
    80207966:	4c4080e7          	jalr	1220(ra) # 80208e26 <virtio_disk_rw>
}
    8020796a:	0001                	nop
    8020796c:	60e2                	ld	ra,24(sp)
    8020796e:	6442                	ld	s0,16(sp)
    80207970:	6105                	addi	sp,sp,32
    80207972:	8082                	ret

0000000080207974 <disk_intr>:

void
disk_intr(void) {
    80207974:	1141                	addi	sp,sp,-16
    80207976:	e406                	sd	ra,8(sp)
    80207978:	e022                	sd	s0,0(sp)
    8020797a:	0800                	addi	s0,sp,16
    virtio_disk_intr();
    8020797c:	00002097          	auipc	ra,0x2
    80207980:	866080e7          	jalr	-1946(ra) # 802091e2 <virtio_disk_intr>
}
    80207984:	0001                	nop
    80207986:	60a2                	ld	ra,8(sp)
    80207988:	6402                	ld	s0,0(sp)
    8020798a:	0141                	addi	sp,sp,16
    8020798c:	8082                	ret

000000008020798e <copy_path>:
sysfile_unlock(void) {
    spinlock_release(&file_lk);
}

static int
copy_path(char** to, const char* from) {
    8020798e:	1101                	addi	sp,sp,-32
    80207990:	ec06                	sd	ra,24(sp)
    80207992:	e822                	sd	s0,16(sp)
    80207994:	1000                	addi	s0,sp,32
    80207996:	fea43423          	sd	a0,-24(s0)
    8020799a:	feb43023          	sd	a1,-32(s0)
    *to = kmalloc(strlen(from) + 1);
    8020799e:	fe043503          	ld	a0,-32(s0)
    802079a2:	ffffb097          	auipc	ra,0xffffb
    802079a6:	4ca080e7          	jalr	1226(ra) # 80202e6c <strlen>
    802079aa:	87aa                	mv	a5,a0
    802079ac:	0785                	addi	a5,a5,1
    802079ae:	853e                	mv	a0,a5
    802079b0:	ffff9097          	auipc	ra,0xffff9
    802079b4:	2b0080e7          	jalr	688(ra) # 80200c60 <kmalloc>
    802079b8:	872a                	mv	a4,a0
    802079ba:	fe843783          	ld	a5,-24(s0)
    802079be:	e398                	sd	a4,0(a5)
    if (*to == NULL)
    802079c0:	fe843783          	ld	a5,-24(s0)
    802079c4:	639c                	ld	a5,0(a5)
    802079c6:	e399                	bnez	a5,802079cc <copy_path+0x3e>
        return -E_NO_MEM;
    802079c8:	57f1                	li	a5,-4
    802079ca:	a821                	j	802079e2 <copy_path+0x54>
    strcpy(*to, from);
    802079cc:	fe843783          	ld	a5,-24(s0)
    802079d0:	639c                	ld	a5,0(a5)
    802079d2:	fe043583          	ld	a1,-32(s0)
    802079d6:	853e                	mv	a0,a5
    802079d8:	ffffb097          	auipc	ra,0xffffb
    802079dc:	368080e7          	jalr	872(ra) # 80202d40 <strcpy>
    return 0;
    802079e0:	4781                	li	a5,0
}
    802079e2:	853e                	mv	a0,a5
    802079e4:	60e2                	ld	ra,24(sp)
    802079e6:	6442                	ld	s0,16(sp)
    802079e8:	6105                	addi	sp,sp,32
    802079ea:	8082                	ret

00000000802079ec <sysfile_init>:

void
sysfile_init() {  // TODO
    802079ec:	1141                	addi	sp,sp,-16
    802079ee:	e406                	sd	ra,8(sp)
    802079f0:	e022                	sd	s0,0(sp)
    802079f2:	0800                	addi	s0,sp,16
    spinlock_init(&file_lk, "sysfile_lk");
    802079f4:	00004597          	auipc	a1,0x4
    802079f8:	d7458593          	addi	a1,a1,-652 # 8020b768 <illegal+0x1a8>
    802079fc:	00325517          	auipc	a0,0x325
    80207a00:	6d450513          	addi	a0,a0,1748 # 8052d0d0 <file_lk>
    80207a04:	ffffd097          	auipc	ra,0xffffd
    80207a08:	f1e080e7          	jalr	-226(ra) # 80204922 <spinlock_init>
}
    80207a0c:	0001                	nop
    80207a0e:	60a2                	ld	ra,8(sp)
    80207a10:	6402                	ld	s0,0(sp)
    80207a12:	0141                	addi	sp,sp,16
    80207a14:	8082                	ret

0000000080207a16 <sysfile_testfd>:

static dirent_t*
sysfile_testfd(const char* __path) {
    80207a16:	7169                	addi	sp,sp,-304
    80207a18:	f606                	sd	ra,296(sp)
    80207a1a:	f222                	sd	s0,288(sp)
    80207a1c:	1a00                	addi	s0,sp,304
    80207a1e:	eca43c23          	sd	a0,-296(s0)
    char* path;
    if (copy_path(&path, __path) < 0)
    80207a22:	fe040793          	addi	a5,s0,-32
    80207a26:	ed843583          	ld	a1,-296(s0)
    80207a2a:	853e                	mv	a0,a5
    80207a2c:	00000097          	auipc	ra,0x0
    80207a30:	f62080e7          	jalr	-158(ra) # 8020798e <copy_path>
    80207a34:	87aa                	mv	a5,a0
    80207a36:	0007d463          	bgez	a5,80207a3e <sysfile_testfd+0x28>
        return NULL;
    80207a3a:	4781                	li	a5,0
    80207a3c:	a03d                	j	80207a6a <sysfile_testfd+0x54>
    char name[FAT32_MAX_FILENAME + 1];
    dirent_t* dentry = __fat32_lookupPath(path, FALSE, name);
    80207a3e:	fe043783          	ld	a5,-32(s0)
    80207a42:	ee040713          	addi	a4,s0,-288
    80207a46:	863a                	mv	a2,a4
    80207a48:	4581                	li	a1,0
    80207a4a:	853e                	mv	a0,a5
    80207a4c:	fffff097          	auipc	ra,0xfffff
    80207a50:	10c080e7          	jalr	268(ra) # 80206b58 <__fat32_lookupPath>
    80207a54:	fea43423          	sd	a0,-24(s0)
    kmfree(path);
    80207a58:	fe043783          	ld	a5,-32(s0)
    80207a5c:	853e                	mv	a0,a5
    80207a5e:	ffff9097          	auipc	ra,0xffff9
    80207a62:	25a080e7          	jalr	602(ra) # 80200cb8 <kmfree>
    return dentry;
    80207a66:	fe843783          	ld	a5,-24(s0)
}
    80207a6a:	853e                	mv	a0,a5
    80207a6c:	70b2                	ld	ra,296(sp)
    80207a6e:	7412                	ld	s0,288(sp)
    80207a70:	6155                	addi	sp,sp,304
    80207a72:	8082                	ret

0000000080207a74 <__sysfile_create>:

dirent_t*
__sysfile_create(char* path, uint32_t type, uint32_t mode) {  // TODO mode有问题
    80207a74:	7169                	addi	sp,sp,-304
    80207a76:	f606                	sd	ra,296(sp)
    80207a78:	f222                	sd	s0,288(sp)
    80207a7a:	1a00                	addi	s0,sp,304
    80207a7c:	eca43c23          	sd	a0,-296(s0)
    80207a80:	87ae                	mv	a5,a1
    80207a82:	8732                	mv	a4,a2
    80207a84:	ecf42a23          	sw	a5,-300(s0)
    80207a88:	87ba                	mv	a5,a4
    80207a8a:	ecf42823          	sw	a5,-304(s0)
    struct dirent_t *tentry, *dentry;
    char name[FAT32_MAX_FILENAME + 1];
    dentry = __fat32_nameParent(path, name);
    80207a8e:	ee040793          	addi	a5,s0,-288
    80207a92:	85be                	mv	a1,a5
    80207a94:	ed843503          	ld	a0,-296(s0)
    80207a98:	fffff097          	auipc	ra,0xfffff
    80207a9c:	76c080e7          	jalr	1900(ra) # 80207204 <__fat32_nameParent>
    80207aa0:	fea43423          	sd	a0,-24(s0)
    kmfree(path);
    80207aa4:	ed843503          	ld	a0,-296(s0)
    80207aa8:	ffff9097          	auipc	ra,0xffff9
    80207aac:	210080e7          	jalr	528(ra) # 80200cb8 <kmfree>
    if (dentry == NULL)
    80207ab0:	fe843783          	ld	a5,-24(s0)
    80207ab4:	e399                	bnez	a5,80207aba <__sysfile_create+0x46>
        return NULL;
    80207ab6:	4781                	li	a5,0
    80207ab8:	a8cd                	j	80207baa <__sysfile_create+0x136>

    if (type == S_IFDIR)
    80207aba:	ed442783          	lw	a5,-300(s0)
    80207abe:	0007871b          	sext.w	a4,a5
    80207ac2:	6791                	lui	a5,0x4
    80207ac4:	00f71663          	bne	a4,a5,80207ad0 <__sysfile_create+0x5c>
        mode = ATTR_DIRECTORY;
    80207ac8:	47c1                	li	a5,16
    80207aca:	ecf42823          	sw	a5,-304(s0)
    80207ace:	a019                	j	80207ad4 <__sysfile_create+0x60>
    else if (mode & O_RDONLY)
        mode = ATTR_READ_ONLY;
    else
        mode = 0;
    80207ad0:	ec042823          	sw	zero,-304(s0)

    dentry_lock(dentry);
    80207ad4:	fe843503          	ld	a0,-24(s0)
    80207ad8:	ffffe097          	auipc	ra,0xffffe
    80207adc:	012080e7          	jalr	18(ra) # 80205aea <dentry_lock>
    if ((tentry = __fat32_alloc(dentry, name, mode)) == NULL) {
    80207ae0:	ed042703          	lw	a4,-304(s0)
    80207ae4:	ee040793          	addi	a5,s0,-288
    80207ae8:	863a                	mv	a2,a4
    80207aea:	85be                	mv	a1,a5
    80207aec:	fe843503          	ld	a0,-24(s0)
    80207af0:	fffff097          	auipc	ra,0xfffff
    80207af4:	510080e7          	jalr	1296(ra) # 80207000 <__fat32_alloc>
    80207af8:	fea43023          	sd	a0,-32(s0)
    80207afc:	fe043783          	ld	a5,-32(s0)
    80207b00:	ef99                	bnez	a5,80207b1e <__sysfile_create+0xaa>
        dentry_unlock(dentry);
    80207b02:	fe843503          	ld	a0,-24(s0)
    80207b06:	ffffe097          	auipc	ra,0xffffe
    80207b0a:	02c080e7          	jalr	44(ra) # 80205b32 <dentry_unlock>
        __fat32_put(dentry);
    80207b0e:	fe843503          	ld	a0,-24(s0)
    80207b12:	fffff097          	auipc	ra,0xfffff
    80207b16:	c7c080e7          	jalr	-900(ra) # 8020678e <__fat32_put>
        return NULL;
    80207b1a:	4781                	li	a5,0
    80207b1c:	a079                	j	80207baa <__sysfile_create+0x136>
    }

    if ((type == S_IFDIR && !(tentry->d_type & ATTR_DIRECTORY)) || (type == S_IFREG && (tentry->d_type & ATTR_DIRECTORY))) {
    80207b1e:	ed442783          	lw	a5,-300(s0)
    80207b22:	0007871b          	sext.w	a4,a5
    80207b26:	6791                	lui	a5,0x4
    80207b28:	00f71a63          	bne	a4,a5,80207b3c <__sysfile_create+0xc8>
    80207b2c:	fe043783          	ld	a5,-32(s0)
    80207b30:	0147c783          	lbu	a5,20(a5) # 4014 <_entry-0x801fbfec>
    80207b34:	2781                	sext.w	a5,a5
    80207b36:	8bc1                	andi	a5,a5,16
    80207b38:	2781                	sext.w	a5,a5
    80207b3a:	c385                	beqz	a5,80207b5a <__sysfile_create+0xe6>
    80207b3c:	ed442783          	lw	a5,-300(s0)
    80207b40:	0007871b          	sext.w	a4,a5
    80207b44:	67a1                	lui	a5,0x8
    80207b46:	02f71e63          	bne	a4,a5,80207b82 <__sysfile_create+0x10e>
    80207b4a:	fe043783          	ld	a5,-32(s0)
    80207b4e:	0147c783          	lbu	a5,20(a5) # 8014 <_entry-0x801f7fec>
    80207b52:	2781                	sext.w	a5,a5
    80207b54:	8bc1                	andi	a5,a5,16
    80207b56:	2781                	sext.w	a5,a5
    80207b58:	c78d                	beqz	a5,80207b82 <__sysfile_create+0x10e>
        dentry_unlock(dentry);
    80207b5a:	fe843503          	ld	a0,-24(s0)
    80207b5e:	ffffe097          	auipc	ra,0xffffe
    80207b62:	fd4080e7          	jalr	-44(ra) # 80205b32 <dentry_unlock>
        __fat32_put(tentry);
    80207b66:	fe043503          	ld	a0,-32(s0)
    80207b6a:	fffff097          	auipc	ra,0xfffff
    80207b6e:	c24080e7          	jalr	-988(ra) # 8020678e <__fat32_put>
        __fat32_put(dentry);
    80207b72:	fe843503          	ld	a0,-24(s0)
    80207b76:	fffff097          	auipc	ra,0xfffff
    80207b7a:	c18080e7          	jalr	-1000(ra) # 8020678e <__fat32_put>
        return NULL;
    80207b7e:	4781                	li	a5,0
    80207b80:	a02d                	j	80207baa <__sysfile_create+0x136>
    }
    dentry_unlock(dentry);
    80207b82:	fe843503          	ld	a0,-24(s0)
    80207b86:	ffffe097          	auipc	ra,0xffffe
    80207b8a:	fac080e7          	jalr	-84(ra) # 80205b32 <dentry_unlock>
    __fat32_put(dentry);
    80207b8e:	fe843503          	ld	a0,-24(s0)
    80207b92:	fffff097          	auipc	ra,0xfffff
    80207b96:	bfc080e7          	jalr	-1028(ra) # 8020678e <__fat32_put>

    dentry_unlock(tentry);
    80207b9a:	fe043503          	ld	a0,-32(s0)
    80207b9e:	ffffe097          	auipc	ra,0xffffe
    80207ba2:	f94080e7          	jalr	-108(ra) # 80205b32 <dentry_unlock>
    return tentry;
    80207ba6:	fe043783          	ld	a5,-32(s0)
}
    80207baa:	853e                	mv	a0,a5
    80207bac:	70b2                	ld	ra,296(sp)
    80207bae:	7412                	ld	s0,288(sp)
    80207bb0:	6155                	addi	sp,sp,304
    80207bb2:	8082                	ret

0000000080207bb4 <sysfile_open>:
sysfile_fsync(int fd) {
    return file_fsync(fd);
}
*/
int
sysfile_open(int fd, const char* __path, uint32_t flags) {
    80207bb4:	711d                	addi	sp,sp,-96
    80207bb6:	ec86                	sd	ra,88(sp)
    80207bb8:	e8a2                	sd	s0,80(sp)
    80207bba:	1080                	addi	s0,sp,96
    80207bbc:	87aa                	mv	a5,a0
    80207bbe:	fab43023          	sd	a1,-96(s0)
    80207bc2:	8732                	mv	a4,a2
    80207bc4:	faf42623          	sw	a5,-84(s0)
    80207bc8:	87ba                	mv	a5,a4
    80207bca:	faf42423          	sw	a5,-88(s0)
    spinlock_acquire(&getCurrentProc()->lk);
    80207bce:	ffffa097          	auipc	ra,0xffffa
    80207bd2:	000080e7          	jalr	ra # 80201bce <getCurrentProc>
    80207bd6:	87aa                	mv	a5,a0
    80207bd8:	56878793          	addi	a5,a5,1384
    80207bdc:	853e                	mv	a0,a5
    80207bde:	ffffd097          	auipc	ra,0xffffd
    80207be2:	d74080e7          	jalr	-652(ra) # 80204952 <spinlock_acquire>

    char* path;
    dirent_t* dentry;
    dirent_t* oldCwd = getCurrentProc()->cwd;
    80207be6:	ffffa097          	auipc	ra,0xffffa
    80207bea:	fe8080e7          	jalr	-24(ra) # 80201bce <getCurrentProc>
    80207bee:	87aa                	mv	a5,a0
    80207bf0:	7bdc                	ld	a5,176(a5)
    80207bf2:	fcf43c23          	sd	a5,-40(s0)
    int ret;
    copy_path(&path, __path);
    80207bf6:	fb840793          	addi	a5,s0,-72
    80207bfa:	fa043583          	ld	a1,-96(s0)
    80207bfe:	853e                	mv	a0,a5
    80207c00:	00000097          	auipc	ra,0x0
    80207c04:	d8e080e7          	jalr	-626(ra) # 8020798e <copy_path>
    if (path == NULL)
    80207c08:	fb843783          	ld	a5,-72(s0)
    80207c0c:	e399                	bnez	a5,80207c12 <sysfile_open+0x5e>
        return -E_NO_MEM;
    80207c0e:	57f1                	li	a5,-4
    80207c10:	acb1                	j	80207e6c <sysfile_open+0x2b8>
    if (fd >= 0) {
    80207c12:	fac42783          	lw	a5,-84(s0)
    80207c16:	2781                	sext.w	a5,a5
    80207c18:	0407c363          	bltz	a5,80207c5e <sysfile_open+0xaa>
        file_t* f = getCurrentProc()->openFiles[fd];
    80207c1c:	ffffa097          	auipc	ra,0xffffa
    80207c20:	fb2080e7          	jalr	-78(ra) # 80201bce <getCurrentProc>
    80207c24:	872a                	mv	a4,a0
    80207c26:	fac42783          	lw	a5,-84(s0)
    80207c2a:	07d9                	addi	a5,a5,22
    80207c2c:	078e                	slli	a5,a5,0x3
    80207c2e:	97ba                	add	a5,a5,a4
    80207c30:	679c                	ld	a5,8(a5)
    80207c32:	fcf43823          	sd	a5,-48(s0)
        if (f == NULL || f->openCount == 0) {
    80207c36:	fd043783          	ld	a5,-48(s0)
    80207c3a:	c789                	beqz	a5,80207c44 <sysfile_open+0x90>
    80207c3c:	fd043783          	ld	a5,-48(s0)
    80207c40:	5b9c                	lw	a5,48(a5)
    80207c42:	e789                	bnez	a5,80207c4c <sysfile_open+0x98>
            ret = -E_INVAL;
    80207c44:	57f5                	li	a5,-3
    80207c46:	fef42223          	sw	a5,-28(s0)
            goto out;
    80207c4a:	aaf9                	j	80207e28 <sysfile_open+0x274>
        }
        getCurrentProc()->cwd = f->d_entry;
    80207c4c:	ffffa097          	auipc	ra,0xffffa
    80207c50:	f82080e7          	jalr	-126(ra) # 80201bce <getCurrentProc>
    80207c54:	872a                	mv	a4,a0
    80207c56:	fd043783          	ld	a5,-48(s0)
    80207c5a:	779c                	ld	a5,40(a5)
    80207c5c:	fb5c                	sd	a5,176(a4)
    }
    if (flags & O_CREATE) {  //新建文件
    80207c5e:	fa842783          	lw	a5,-88(s0)
    80207c62:	0407f793          	andi	a5,a5,64
    80207c66:	2781                	sext.w	a5,a5
    80207c68:	c78d                	beqz	a5,80207c92 <sysfile_open+0xde>
        dentry = __sysfile_create(path, S_IFREG, flags);
    80207c6a:	fb843783          	ld	a5,-72(s0)
    80207c6e:	fa842703          	lw	a4,-88(s0)
    80207c72:	863a                	mv	a2,a4
    80207c74:	65a1                	lui	a1,0x8
    80207c76:	853e                	mv	a0,a5
    80207c78:	00000097          	auipc	ra,0x0
    80207c7c:	dfc080e7          	jalr	-516(ra) # 80207a74 <__sysfile_create>
    80207c80:	fea43423          	sd	a0,-24(s0)
        if (dentry == NULL) {
    80207c84:	fe843783          	ld	a5,-24(s0)
    80207c88:	e7bd                	bnez	a5,80207cf6 <sysfile_open+0x142>
            ret = -E_NOENTRY;
    80207c8a:	57c1                	li	a5,-16
    80207c8c:	fef42223          	sw	a5,-28(s0)
            goto out;
    80207c90:	aa61                	j	80207e28 <sysfile_open+0x274>
        }
    } else {
        dentry = __fat32_name(path);
    80207c92:	fb843783          	ld	a5,-72(s0)
    80207c96:	853e                	mv	a0,a5
    80207c98:	fffff097          	auipc	ra,0xfffff
    80207c9c:	540080e7          	jalr	1344(ra) # 802071d8 <__fat32_name>
    80207ca0:	fea43423          	sd	a0,-24(s0)
        if (dentry == NULL) {
    80207ca4:	fe843783          	ld	a5,-24(s0)
    80207ca8:	e789                	bnez	a5,80207cb2 <sysfile_open+0xfe>
            ret = -E_NOENTRY;
    80207caa:	57c1                	li	a5,-16
    80207cac:	fef42223          	sw	a5,-28(s0)
            goto out;
    80207cb0:	aaa5                	j	80207e28 <sysfile_open+0x274>
        }
        dentry_lock(dentry);
    80207cb2:	fe843503          	ld	a0,-24(s0)
    80207cb6:	ffffe097          	auipc	ra,0xffffe
    80207cba:	e34080e7          	jalr	-460(ra) # 80205aea <dentry_lock>
        if ((dentry->d_type & ATTR_DIRECTORY) && (flags != O_RDONLY)) {
    80207cbe:	fe843783          	ld	a5,-24(s0)
    80207cc2:	0147c783          	lbu	a5,20(a5)
    80207cc6:	2781                	sext.w	a5,a5
    80207cc8:	8bc1                	andi	a5,a5,16
    80207cca:	2781                	sext.w	a5,a5
    80207ccc:	c78d                	beqz	a5,80207cf6 <sysfile_open+0x142>
    80207cce:	fa842783          	lw	a5,-88(s0)
    80207cd2:	2781                	sext.w	a5,a5
    80207cd4:	c38d                	beqz	a5,80207cf6 <sysfile_open+0x142>
            dentry_unlock(dentry);
    80207cd6:	fe843503          	ld	a0,-24(s0)
    80207cda:	ffffe097          	auipc	ra,0xffffe
    80207cde:	e58080e7          	jalr	-424(ra) # 80205b32 <dentry_unlock>
            __fat32_put(dentry);
    80207ce2:	fe843503          	ld	a0,-24(s0)
    80207ce6:	fffff097          	auipc	ra,0xfffff
    80207cea:	aa8080e7          	jalr	-1368(ra) # 8020678e <__fat32_put>
            ret = -E_INVAL;
    80207cee:	57f5                	li	a5,-3
    80207cf0:	fef42223          	sw	a5,-28(s0)
            goto out;
    80207cf4:	aa15                	j	80207e28 <sysfile_open+0x274>
        }
    }
    file_t* f = __file_alloc();
    80207cf6:	00000097          	auipc	ra,0x0
    80207cfa:	a66080e7          	jalr	-1434(ra) # 8020775c <__file_alloc>
    80207cfe:	fca43423          	sd	a0,-56(s0)
    if (f == NULL) {
    80207d02:	fc843783          	ld	a5,-56(s0)
    80207d06:	e789                	bnez	a5,80207d10 <sysfile_open+0x15c>
        ret = -1;
    80207d08:	57fd                	li	a5,-1
    80207d0a:	fef42223          	sw	a5,-28(s0)
        goto out;
    80207d0e:	aa29                	j	80207e28 <sysfile_open+0x274>
    }
    int __fd = __fd_alloc(f);
    80207d10:	fc843503          	ld	a0,-56(s0)
    80207d14:	00000097          	auipc	ra,0x0
    80207d18:	9d8080e7          	jalr	-1576(ra) # 802076ec <__fd_alloc>
    80207d1c:	87aa                	mv	a5,a0
    80207d1e:	fcf42223          	sw	a5,-60(s0)
    if (__fd < 0) {
    80207d22:	fc442783          	lw	a5,-60(s0)
    80207d26:	2781                	sext.w	a5,a5
    80207d28:	0007dc63          	bgez	a5,80207d40 <sysfile_open+0x18c>
        __file_close(f);
    80207d2c:	fc843503          	ld	a0,-56(s0)
    80207d30:	00000097          	auipc	ra,0x0
    80207d34:	b5e080e7          	jalr	-1186(ra) # 8020788e <__file_close>
        ret = -1;
    80207d38:	57fd                	li	a5,-1
    80207d3a:	fef42223          	sw	a5,-28(s0)
        goto out;
    80207d3e:	a0ed                	j	80207e28 <sysfile_open+0x274>
    }

    if (!(dentry->d_type & ATTR_DIRECTORY) && (flags & O_TRUNC))
    80207d40:	fe843783          	ld	a5,-24(s0)
    80207d44:	0147c783          	lbu	a5,20(a5)
    80207d48:	2781                	sext.w	a5,a5
    80207d4a:	8bc1                	andi	a5,a5,16
    80207d4c:	2781                	sext.w	a5,a5
    80207d4e:	ef81                	bnez	a5,80207d66 <sysfile_open+0x1b2>
    80207d50:	fa842783          	lw	a5,-88(s0)
    80207d54:	8bc1                	andi	a5,a5,16
    80207d56:	2781                	sext.w	a5,a5
    80207d58:	c799                	beqz	a5,80207d66 <sysfile_open+0x1b2>
        __fat32_trunc(dentry);
    80207d5a:	fe843503          	ld	a0,-24(s0)
    80207d5e:	ffffe097          	auipc	ra,0xffffe
    80207d62:	2dc080e7          	jalr	732(ra) # 8020603a <__fat32_trunc>

    f->type = FD_ENTRY;
    80207d66:	fc843783          	ld	a5,-56(s0)
    80207d6a:	4709                	li	a4,2
    80207d6c:	c3d8                	sw	a4,4(a5)
    f->pos = (flags & O_APPEND) ? dentry->size : 0;
    80207d6e:	fa842783          	lw	a5,-88(s0)
    80207d72:	0207f793          	andi	a5,a5,32
    80207d76:	2781                	sext.w	a5,a5
    80207d78:	cb81                	beqz	a5,80207d88 <sysfile_open+0x1d4>
    80207d7a:	fe843783          	ld	a5,-24(s0)
    80207d7e:	1347a783          	lw	a5,308(a5)
    80207d82:	1782                	slli	a5,a5,0x20
    80207d84:	9381                	srli	a5,a5,0x20
    80207d86:	a011                	j	80207d8a <sysfile_open+0x1d6>
    80207d88:	4781                	li	a5,0
    80207d8a:	fc843703          	ld	a4,-56(s0)
    80207d8e:	ef1c                	sd	a5,24(a4)
    f->d_entry = dentry;
    80207d90:	fc843783          	ld	a5,-56(s0)
    80207d94:	fe843703          	ld	a4,-24(s0)
    80207d98:	f798                	sd	a4,40(a5)
    f->readable = (flags == O_RDONLY) || ((flags & O_RDWR) && (flags != O_WRONLY));
    80207d9a:	fa842783          	lw	a5,-88(s0)
    80207d9e:	2781                	sext.w	a5,a5
    80207da0:	cf89                	beqz	a5,80207dba <sysfile_open+0x206>
    80207da2:	fa842783          	lw	a5,-88(s0)
    80207da6:	8b89                	andi	a5,a5,2
    80207da8:	2781                	sext.w	a5,a5
    80207daa:	cb91                	beqz	a5,80207dbe <sysfile_open+0x20a>
    80207dac:	fa842783          	lw	a5,-88(s0)
    80207db0:	0007871b          	sext.w	a4,a5
    80207db4:	4785                	li	a5,1
    80207db6:	00f70463          	beq	a4,a5,80207dbe <sysfile_open+0x20a>
    80207dba:	4785                	li	a5,1
    80207dbc:	a011                	j	80207dc0 <sysfile_open+0x20c>
    80207dbe:	4781                	li	a5,0
    80207dc0:	fc843703          	ld	a4,-56(s0)
    80207dc4:	c71c                	sw	a5,8(a4)
    f->writeable = flags & O_WRONLY;
    80207dc6:	fa842783          	lw	a5,-88(s0)
    80207dca:	8b85                	andi	a5,a5,1
    80207dcc:	0007871b          	sext.w	a4,a5
    80207dd0:	fc843783          	ld	a5,-56(s0)
    80207dd4:	c7d8                	sw	a4,12(a5)
    dentry_unlock(dentry);
    80207dd6:	fe843503          	ld	a0,-24(s0)
    80207dda:	ffffe097          	auipc	ra,0xffffe
    80207dde:	d58080e7          	jalr	-680(ra) # 80205b32 <dentry_unlock>

    kmfree(path);
    80207de2:	fb843783          	ld	a5,-72(s0)
    80207de6:	853e                	mv	a0,a5
    80207de8:	ffff9097          	auipc	ra,0xffff9
    80207dec:	ed0080e7          	jalr	-304(ra) # 80200cb8 <kmfree>
    if (fd >= 0) {
    80207df0:	fac42783          	lw	a5,-84(s0)
    80207df4:	2781                	sext.w	a5,a5
    80207df6:	0207c663          	bltz	a5,80207e22 <sysfile_open+0x26e>
        getCurrentProc()->cwd = oldCwd;
    80207dfa:	ffffa097          	auipc	ra,0xffffa
    80207dfe:	dd4080e7          	jalr	-556(ra) # 80201bce <getCurrentProc>
    80207e02:	872a                	mv	a4,a0
    80207e04:	fd843783          	ld	a5,-40(s0)
    80207e08:	fb5c                	sd	a5,176(a4)
        spinlock_release(&getCurrentProc()->lk);
    80207e0a:	ffffa097          	auipc	ra,0xffffa
    80207e0e:	dc4080e7          	jalr	-572(ra) # 80201bce <getCurrentProc>
    80207e12:	87aa                	mv	a5,a0
    80207e14:	56878793          	addi	a5,a5,1384
    80207e18:	853e                	mv	a0,a5
    80207e1a:	ffffd097          	auipc	ra,0xffffd
    80207e1e:	bae080e7          	jalr	-1106(ra) # 802049c8 <spinlock_release>
    }
    return __fd;
    80207e22:	fc442783          	lw	a5,-60(s0)
    80207e26:	a099                	j	80207e6c <sysfile_open+0x2b8>

out:
    if (fd >= 0) {
    80207e28:	fac42783          	lw	a5,-84(s0)
    80207e2c:	2781                	sext.w	a5,a5
    80207e2e:	0207c663          	bltz	a5,80207e5a <sysfile_open+0x2a6>
        getCurrentProc()->cwd = oldCwd;
    80207e32:	ffffa097          	auipc	ra,0xffffa
    80207e36:	d9c080e7          	jalr	-612(ra) # 80201bce <getCurrentProc>
    80207e3a:	872a                	mv	a4,a0
    80207e3c:	fd843783          	ld	a5,-40(s0)
    80207e40:	fb5c                	sd	a5,176(a4)
        spinlock_release(&getCurrentProc()->lk);
    80207e42:	ffffa097          	auipc	ra,0xffffa
    80207e46:	d8c080e7          	jalr	-628(ra) # 80201bce <getCurrentProc>
    80207e4a:	87aa                	mv	a5,a0
    80207e4c:	56878793          	addi	a5,a5,1384
    80207e50:	853e                	mv	a0,a5
    80207e52:	ffffd097          	auipc	ra,0xffffd
    80207e56:	b76080e7          	jalr	-1162(ra) # 802049c8 <spinlock_release>
    }
    kmfree(path);
    80207e5a:	fb843783          	ld	a5,-72(s0)
    80207e5e:	853e                	mv	a0,a5
    80207e60:	ffff9097          	auipc	ra,0xffff9
    80207e64:	e58080e7          	jalr	-424(ra) # 80200cb8 <kmfree>
    return ret;
    80207e68:	fe442783          	lw	a5,-28(s0)
}
    80207e6c:	853e                	mv	a0,a5
    80207e6e:	60e6                	ld	ra,88(sp)
    80207e70:	6446                	ld	s0,80(sp)
    80207e72:	6125                	addi	sp,sp,96
    80207e74:	8082                	ret

0000000080207e76 <sysfile_close>:

int
sysfile_close(int fd) {
    80207e76:	7179                	addi	sp,sp,-48
    80207e78:	f406                	sd	ra,40(sp)
    80207e7a:	f022                	sd	s0,32(sp)
    80207e7c:	1800                	addi	s0,sp,48
    80207e7e:	87aa                	mv	a5,a0
    80207e80:	fcf42e23          	sw	a5,-36(s0)
    file_t* f = getCurrentProc()->openFiles[fd];
    80207e84:	ffffa097          	auipc	ra,0xffffa
    80207e88:	d4a080e7          	jalr	-694(ra) # 80201bce <getCurrentProc>
    80207e8c:	872a                	mv	a4,a0
    80207e8e:	fdc42783          	lw	a5,-36(s0)
    80207e92:	07d9                	addi	a5,a5,22
    80207e94:	078e                	slli	a5,a5,0x3
    80207e96:	97ba                	add	a5,a5,a4
    80207e98:	679c                	ld	a5,8(a5)
    80207e9a:	fef43423          	sd	a5,-24(s0)
    getCurrentProc()->openFiles[fd] = NULL;
    80207e9e:	ffffa097          	auipc	ra,0xffffa
    80207ea2:	d30080e7          	jalr	-720(ra) # 80201bce <getCurrentProc>
    80207ea6:	872a                	mv	a4,a0
    80207ea8:	fdc42783          	lw	a5,-36(s0)
    80207eac:	07d9                	addi	a5,a5,22
    80207eae:	078e                	slli	a5,a5,0x3
    80207eb0:	97ba                	add	a5,a5,a4
    80207eb2:	0007b423          	sd	zero,8(a5)
    return __file_close(f);
    80207eb6:	fe843503          	ld	a0,-24(s0)
    80207eba:	00000097          	auipc	ra,0x0
    80207ebe:	9d4080e7          	jalr	-1580(ra) # 8020788e <__file_close>
    80207ec2:	87aa                	mv	a5,a0
}
    80207ec4:	853e                	mv	a0,a5
    80207ec6:	70a2                	ld	ra,40(sp)
    80207ec8:	7402                	ld	s0,32(sp)
    80207eca:	6145                	addi	sp,sp,48
    80207ecc:	8082                	ret

0000000080207ece <sysfile_read>:

int
sysfile_read(int fd, void* dst, size_t len) {
    80207ece:	715d                	addi	sp,sp,-80
    80207ed0:	e486                	sd	ra,72(sp)
    80207ed2:	e0a2                	sd	s0,64(sp)
    80207ed4:	0880                	addi	s0,sp,80
    80207ed6:	87aa                	mv	a5,a0
    80207ed8:	fcb43023          	sd	a1,-64(s0)
    80207edc:	fac43c23          	sd	a2,-72(s0)
    80207ee0:	fcf42623          	sw	a5,-52(s0)
    file_t* f = getCurrentProc()->openFiles[fd];
    80207ee4:	ffffa097          	auipc	ra,0xffffa
    80207ee8:	cea080e7          	jalr	-790(ra) # 80201bce <getCurrentProc>
    80207eec:	872a                	mv	a4,a0
    80207eee:	fcc42783          	lw	a5,-52(s0)
    80207ef2:	07d9                	addi	a5,a5,22
    80207ef4:	078e                	slli	a5,a5,0x3
    80207ef6:	97ba                	add	a5,a5,a4
    80207ef8:	679c                	ld	a5,8(a5)
    80207efa:	fef43423          	sd	a5,-24(s0)
    if (f == NULL || f->openCount == 0)
    80207efe:	fe843783          	ld	a5,-24(s0)
    80207f02:	c789                	beqz	a5,80207f0c <sysfile_read+0x3e>
    80207f04:	fe843783          	ld	a5,-24(s0)
    80207f08:	5b9c                	lw	a5,48(a5)
    80207f0a:	e399                	bnez	a5,80207f10 <sysfile_read+0x42>
        return -E_INVAL;
    80207f0c:	57f5                	li	a5,-3
    80207f0e:	a095                	j	80207f72 <sysfile_read+0xa4>
    dirent_t* dentry = f->d_entry;
    80207f10:	fe843783          	ld	a5,-24(s0)
    80207f14:	779c                	ld	a5,40(a5)
    80207f16:	fef43023          	sd	a5,-32(s0)

    dentry_lock(dentry);
    80207f1a:	fe043503          	ld	a0,-32(s0)
    80207f1e:	ffffe097          	auipc	ra,0xffffe
    80207f22:	bcc080e7          	jalr	-1076(ra) # 80205aea <dentry_lock>
    int ret = __fat32_read(dentry, 0, dst, f->pos, &len);
    80207f26:	fe843783          	ld	a5,-24(s0)
    80207f2a:	6f9c                	ld	a5,24(a5)
    80207f2c:	2781                	sext.w	a5,a5
    80207f2e:	fb840713          	addi	a4,s0,-72
    80207f32:	86be                	mv	a3,a5
    80207f34:	fc043603          	ld	a2,-64(s0)
    80207f38:	4581                	li	a1,0
    80207f3a:	fe043503          	ld	a0,-32(s0)
    80207f3e:	ffffe097          	auipc	ra,0xffffe
    80207f42:	cc8080e7          	jalr	-824(ra) # 80205c06 <__fat32_read>
    80207f46:	87aa                	mv	a5,a0
    80207f48:	fcf42e23          	sw	a5,-36(s0)
    f->pos += len;
    80207f4c:	fe843783          	ld	a5,-24(s0)
    80207f50:	6f9c                	ld	a5,24(a5)
    80207f52:	873e                	mv	a4,a5
    80207f54:	fb843783          	ld	a5,-72(s0)
    80207f58:	97ba                	add	a5,a5,a4
    80207f5a:	873e                	mv	a4,a5
    80207f5c:	fe843783          	ld	a5,-24(s0)
    80207f60:	ef98                	sd	a4,24(a5)
    dentry_unlock(dentry);
    80207f62:	fe043503          	ld	a0,-32(s0)
    80207f66:	ffffe097          	auipc	ra,0xffffe
    80207f6a:	bcc080e7          	jalr	-1076(ra) # 80205b32 <dentry_unlock>

    return ret;
    80207f6e:	fdc42783          	lw	a5,-36(s0)
}
    80207f72:	853e                	mv	a0,a5
    80207f74:	60a6                	ld	ra,72(sp)
    80207f76:	6406                	ld	s0,64(sp)
    80207f78:	6161                	addi	sp,sp,80
    80207f7a:	8082                	ret

0000000080207f7c <sysfile_write>:

int
sysfile_write(int fd, void* src, size_t len) {
    80207f7c:	715d                	addi	sp,sp,-80
    80207f7e:	e486                	sd	ra,72(sp)
    80207f80:	e0a2                	sd	s0,64(sp)
    80207f82:	0880                	addi	s0,sp,80
    80207f84:	87aa                	mv	a5,a0
    80207f86:	fcb43023          	sd	a1,-64(s0)
    80207f8a:	fac43c23          	sd	a2,-72(s0)
    80207f8e:	fcf42623          	sw	a5,-52(s0)
    file_t* f = getCurrentProc()->openFiles[fd];
    80207f92:	ffffa097          	auipc	ra,0xffffa
    80207f96:	c3c080e7          	jalr	-964(ra) # 80201bce <getCurrentProc>
    80207f9a:	872a                	mv	a4,a0
    80207f9c:	fcc42783          	lw	a5,-52(s0)
    80207fa0:	07d9                	addi	a5,a5,22
    80207fa2:	078e                	slli	a5,a5,0x3
    80207fa4:	97ba                	add	a5,a5,a4
    80207fa6:	679c                	ld	a5,8(a5)
    80207fa8:	fef43023          	sd	a5,-32(s0)
    if (f == NULL || f->openCount == 0)
    80207fac:	fe043783          	ld	a5,-32(s0)
    80207fb0:	c789                	beqz	a5,80207fba <sysfile_write+0x3e>
    80207fb2:	fe043783          	ld	a5,-32(s0)
    80207fb6:	5b9c                	lw	a5,48(a5)
    80207fb8:	e399                	bnez	a5,80207fbe <sysfile_write+0x42>
        return -E_INVAL;
    80207fba:	57f5                	li	a5,-3
    80207fbc:	a069                	j	80208046 <sysfile_write+0xca>

    int ret;
    if (f == STDOUT_PTR) {
    80207fbe:	fe043703          	ld	a4,-32(s0)
    80207fc2:	4785                	li	a5,1
    80207fc4:	17a2                	slli	a5,a5,0x28
    80207fc6:	00f71f63          	bne	a4,a5,80207fe4 <sysfile_write+0x68>
        console_write(src, 0, len);
    80207fca:	fb843783          	ld	a5,-72(s0)
    80207fce:	863e                	mv	a2,a5
    80207fd0:	4581                	li	a1,0
    80207fd2:	fc043503          	ld	a0,-64(s0)
    80207fd6:	ffff8097          	auipc	ra,0xffff8
    80207fda:	2e2080e7          	jalr	738(ra) # 802002b8 <console_write>
        ret = 0;
    80207fde:	fe042623          	sw	zero,-20(s0)
    80207fe2:	a085                	j	80208042 <sysfile_write+0xc6>
    } else {
        dirent_t* dentry = f->d_entry;
    80207fe4:	fe043783          	ld	a5,-32(s0)
    80207fe8:	779c                	ld	a5,40(a5)
    80207fea:	fcf43c23          	sd	a5,-40(s0)
        dentry_lock(dentry);
    80207fee:	fd843503          	ld	a0,-40(s0)
    80207ff2:	ffffe097          	auipc	ra,0xffffe
    80207ff6:	af8080e7          	jalr	-1288(ra) # 80205aea <dentry_lock>
        ret = __fat32_write(dentry, 0, src, f->pos, &len);
    80207ffa:	fe043783          	ld	a5,-32(s0)
    80207ffe:	6f9c                	ld	a5,24(a5)
    80208000:	2781                	sext.w	a5,a5
    80208002:	fb840713          	addi	a4,s0,-72
    80208006:	86be                	mv	a3,a5
    80208008:	fc043603          	ld	a2,-64(s0)
    8020800c:	4581                	li	a1,0
    8020800e:	fd843503          	ld	a0,-40(s0)
    80208012:	ffffe097          	auipc	ra,0xffffe
    80208016:	d52080e7          	jalr	-686(ra) # 80205d64 <__fat32_write>
    8020801a:	87aa                	mv	a5,a0
    8020801c:	fef42623          	sw	a5,-20(s0)
        f->pos += len;
    80208020:	fe043783          	ld	a5,-32(s0)
    80208024:	6f9c                	ld	a5,24(a5)
    80208026:	873e                	mv	a4,a5
    80208028:	fb843783          	ld	a5,-72(s0)
    8020802c:	97ba                	add	a5,a5,a4
    8020802e:	873e                	mv	a4,a5
    80208030:	fe043783          	ld	a5,-32(s0)
    80208034:	ef98                	sd	a4,24(a5)
        dentry_unlock(dentry);
    80208036:	fd843503          	ld	a0,-40(s0)
    8020803a:	ffffe097          	auipc	ra,0xffffe
    8020803e:	af8080e7          	jalr	-1288(ra) # 80205b32 <dentry_unlock>
    }

    return ret;  // TODO
    80208042:	fec42783          	lw	a5,-20(s0)
}
    80208046:	853e                	mv	a0,a5
    80208048:	60a6                	ld	ra,72(sp)
    8020804a:	6406                	ld	s0,64(sp)
    8020804c:	6161                	addi	sp,sp,80
    8020804e:	8082                	ret

0000000080208050 <sysfile_seek>:

int
sysfile_seek(int fd, offset_t pos, int startPos) {
    80208050:	7151                	addi	sp,sp,-240
    80208052:	f586                	sd	ra,232(sp)
    80208054:	f1a2                	sd	s0,224(sp)
    80208056:	1980                	addi	s0,sp,240
    80208058:	87aa                	mv	a5,a0
    8020805a:	f0b43823          	sd	a1,-240(s0)
    8020805e:	8732                	mv	a4,a2
    80208060:	f0f42e23          	sw	a5,-228(s0)
    80208064:	87ba                	mv	a5,a4
    80208066:	f0f42c23          	sw	a5,-232(s0)
    // return -E_UNIMP;  // TODO

    file_t* f = getCurrentProc()->openFiles[fd];
    8020806a:	ffffa097          	auipc	ra,0xffffa
    8020806e:	b64080e7          	jalr	-1180(ra) # 80201bce <getCurrentProc>
    80208072:	872a                	mv	a4,a0
    80208074:	f1c42783          	lw	a5,-228(s0)
    80208078:	07d9                	addi	a5,a5,22
    8020807a:	078e                	slli	a5,a5,0x3
    8020807c:	97ba                	add	a5,a5,a4
    8020807e:	679c                	ld	a5,8(a5)
    80208080:	fef43423          	sd	a5,-24(s0)
    if (f == NULL || f->openCount == 0)
    80208084:	fe843783          	ld	a5,-24(s0)
    80208088:	c789                	beqz	a5,80208092 <sysfile_seek+0x42>
    8020808a:	fe843783          	ld	a5,-24(s0)
    8020808e:	5b9c                	lw	a5,48(a5)
    80208090:	e399                	bnez	a5,80208096 <sysfile_seek+0x46>
        return -E_INVAL;
    80208092:	57f5                	li	a5,-3
    80208094:	a061                	j	8020811c <sysfile_seek+0xcc>
    dirent_t* dentry = f->d_entry;
    80208096:	fe843783          	ld	a5,-24(s0)
    8020809a:	779c                	ld	a5,40(a5)
    8020809c:	fef43023          	sd	a5,-32(s0)

    stat_t stat;
    switch (startPos) {
    802080a0:	f1842783          	lw	a5,-232(s0)
    802080a4:	0007871b          	sext.w	a4,a5
    802080a8:	4789                	li	a5,2
    802080aa:	02f70e63          	beq	a4,a5,802080e6 <sysfile_seek+0x96>
    802080ae:	f1842783          	lw	a5,-232(s0)
    802080b2:	0007871b          	sext.w	a4,a5
    802080b6:	4789                	li	a5,2
    802080b8:	04e7c963          	blt	a5,a4,8020810a <sysfile_seek+0xba>
    802080bc:	f1842783          	lw	a5,-232(s0)
    802080c0:	2781                	sext.w	a5,a5
    802080c2:	c7b1                	beqz	a5,8020810e <sysfile_seek+0xbe>
    802080c4:	f1842783          	lw	a5,-232(s0)
    802080c8:	0007871b          	sext.w	a4,a5
    802080cc:	4785                	li	a5,1
    802080ce:	00f70363          	beq	a4,a5,802080d4 <sysfile_seek+0x84>
        case LSEEK_END: {
            __fat32_fstat(dentry, &stat);
            pos = dentry->size;
        } break;
        default:
            break;
    802080d2:	a825                	j	8020810a <sysfile_seek+0xba>
            pos += f->pos;
    802080d4:	fe843783          	ld	a5,-24(s0)
    802080d8:	6f9c                	ld	a5,24(a5)
    802080da:	f1043703          	ld	a4,-240(s0)
    802080de:	97ba                	add	a5,a5,a4
    802080e0:	f0f43823          	sd	a5,-240(s0)
            break;
    802080e4:	a035                	j	80208110 <sysfile_seek+0xc0>
            __fat32_fstat(dentry, &stat);
    802080e6:	f2840793          	addi	a5,s0,-216
    802080ea:	85be                	mv	a1,a5
    802080ec:	fe043503          	ld	a0,-32(s0)
    802080f0:	ffffe097          	auipc	ra,0xffffe
    802080f4:	210080e7          	jalr	528(ra) # 80206300 <__fat32_fstat>
            pos = dentry->size;
    802080f8:	fe043783          	ld	a5,-32(s0)
    802080fc:	1347a783          	lw	a5,308(a5)
    80208100:	1782                	slli	a5,a5,0x20
    80208102:	9381                	srli	a5,a5,0x20
    80208104:	f0f43823          	sd	a5,-240(s0)
        } break;
    80208108:	a021                	j	80208110 <sysfile_seek+0xc0>
            break;
    8020810a:	0001                	nop
    8020810c:	a011                	j	80208110 <sysfile_seek+0xc0>
            break;
    8020810e:	0001                	nop
    }
    f->pos = pos;
    80208110:	fe843783          	ld	a5,-24(s0)
    80208114:	f1043703          	ld	a4,-240(s0)
    80208118:	ef98                	sd	a4,24(a5)
    return 0;
    8020811a:	4781                	li	a5,0
}
    8020811c:	853e                	mv	a0,a5
    8020811e:	70ae                	ld	ra,232(sp)
    80208120:	740e                	ld	s0,224(sp)
    80208122:	616d                	addi	sp,sp,240
    80208124:	8082                	ret

0000000080208126 <sysfile_fstat>:

int
sysfile_fstat(int fd, stat_t* stat) {
    80208126:	7139                	addi	sp,sp,-64
    80208128:	fc06                	sd	ra,56(sp)
    8020812a:	f822                	sd	s0,48(sp)
    8020812c:	0080                	addi	s0,sp,64
    8020812e:	87aa                	mv	a5,a0
    80208130:	fcb43023          	sd	a1,-64(s0)
    80208134:	fcf42623          	sw	a5,-52(s0)
    file_t* f = getCurrentProc()->openFiles[fd];
    80208138:	ffffa097          	auipc	ra,0xffffa
    8020813c:	a96080e7          	jalr	-1386(ra) # 80201bce <getCurrentProc>
    80208140:	872a                	mv	a4,a0
    80208142:	fcc42783          	lw	a5,-52(s0)
    80208146:	07d9                	addi	a5,a5,22
    80208148:	078e                	slli	a5,a5,0x3
    8020814a:	97ba                	add	a5,a5,a4
    8020814c:	679c                	ld	a5,8(a5)
    8020814e:	fef43423          	sd	a5,-24(s0)
    if (f == NULL || f->openCount == 0)
    80208152:	fe843783          	ld	a5,-24(s0)
    80208156:	c789                	beqz	a5,80208160 <sysfile_fstat+0x3a>
    80208158:	fe843783          	ld	a5,-24(s0)
    8020815c:	5b9c                	lw	a5,48(a5)
    8020815e:	e399                	bnez	a5,80208164 <sysfile_fstat+0x3e>
        return -E_INVAL;
    80208160:	57f5                	li	a5,-3
    80208162:	a83d                	j	802081a0 <sysfile_fstat+0x7a>
    dirent_t* dentry = f->d_entry;
    80208164:	fe843783          	ld	a5,-24(s0)
    80208168:	779c                	ld	a5,40(a5)
    8020816a:	fef43023          	sd	a5,-32(s0)
    dentry_lock(dentry);
    8020816e:	fe043503          	ld	a0,-32(s0)
    80208172:	ffffe097          	auipc	ra,0xffffe
    80208176:	978080e7          	jalr	-1672(ra) # 80205aea <dentry_lock>
    int ret = __fat32_fstat(dentry, stat);
    8020817a:	fc043583          	ld	a1,-64(s0)
    8020817e:	fe043503          	ld	a0,-32(s0)
    80208182:	ffffe097          	auipc	ra,0xffffe
    80208186:	17e080e7          	jalr	382(ra) # 80206300 <__fat32_fstat>
    8020818a:	87aa                	mv	a5,a0
    8020818c:	fcf42e23          	sw	a5,-36(s0)
    dentry_unlock(dentry);
    80208190:	fe043503          	ld	a0,-32(s0)
    80208194:	ffffe097          	auipc	ra,0xffffe
    80208198:	99e080e7          	jalr	-1634(ra) # 80205b32 <dentry_unlock>
    return ret;
    8020819c:	fdc42783          	lw	a5,-36(s0)
}
    802081a0:	853e                	mv	a0,a5
    802081a2:	70e2                	ld	ra,56(sp)
    802081a4:	7442                	ld	s0,48(sp)
    802081a6:	6121                	addi	sp,sp,64
    802081a8:	8082                	ret

00000000802081aa <sysfile_fsync>:

int
sysfile_fsync(int fd) {
    802081aa:	7139                	addi	sp,sp,-64
    802081ac:	fc06                	sd	ra,56(sp)
    802081ae:	f822                	sd	s0,48(sp)
    802081b0:	0080                	addi	s0,sp,64
    802081b2:	87aa                	mv	a5,a0
    802081b4:	fcf42623          	sw	a5,-52(s0)
    file_t* f = getCurrentProc()->openFiles[fd];
    802081b8:	ffffa097          	auipc	ra,0xffffa
    802081bc:	a16080e7          	jalr	-1514(ra) # 80201bce <getCurrentProc>
    802081c0:	872a                	mv	a4,a0
    802081c2:	fcc42783          	lw	a5,-52(s0)
    802081c6:	07d9                	addi	a5,a5,22
    802081c8:	078e                	slli	a5,a5,0x3
    802081ca:	97ba                	add	a5,a5,a4
    802081cc:	679c                	ld	a5,8(a5)
    802081ce:	fef43423          	sd	a5,-24(s0)
    if (f == NULL || f->openCount == 0)
    802081d2:	fe843783          	ld	a5,-24(s0)
    802081d6:	c789                	beqz	a5,802081e0 <sysfile_fsync+0x36>
    802081d8:	fe843783          	ld	a5,-24(s0)
    802081dc:	5b9c                	lw	a5,48(a5)
    802081de:	e399                	bnez	a5,802081e4 <sysfile_fsync+0x3a>
        return -E_INVAL;
    802081e0:	57f5                	li	a5,-3
    802081e2:	a82d                	j	8020821c <sysfile_fsync+0x72>
    dirent_t* dentry = f->d_entry;
    802081e4:	fe843783          	ld	a5,-24(s0)
    802081e8:	779c                	ld	a5,40(a5)
    802081ea:	fef43023          	sd	a5,-32(s0)
    dentry_lock(dentry);
    802081ee:	fe043503          	ld	a0,-32(s0)
    802081f2:	ffffe097          	auipc	ra,0xffffe
    802081f6:	8f8080e7          	jalr	-1800(ra) # 80205aea <dentry_lock>
    int ret = __fat32_fsync(dentry);
    802081fa:	fe043503          	ld	a0,-32(s0)
    802081fe:	ffffe097          	auipc	ra,0xffffe
    80208202:	ec6080e7          	jalr	-314(ra) # 802060c4 <__fat32_fsync>
    80208206:	87aa                	mv	a5,a0
    80208208:	fcf42e23          	sw	a5,-36(s0)
    dentry_unlock(dentry);
    8020820c:	fe043503          	ld	a0,-32(s0)
    80208210:	ffffe097          	auipc	ra,0xffffe
    80208214:	922080e7          	jalr	-1758(ra) # 80205b32 <dentry_unlock>
    return ret;
    80208218:	fdc42783          	lw	a5,-36(s0)
}
    8020821c:	853e                	mv	a0,a5
    8020821e:	70e2                	ld	ra,56(sp)
    80208220:	7442                	ld	s0,48(sp)
    80208222:	6121                	addi	sp,sp,64
    80208224:	8082                	ret

0000000080208226 <sysfile_chdir>:

int
sysfile_chdir(const char* __path) {
    80208226:	7179                	addi	sp,sp,-48
    80208228:	f406                	sd	ra,40(sp)
    8020822a:	f022                	sd	s0,32(sp)
    8020822c:	1800                	addi	s0,sp,48
    8020822e:	fca43c23          	sd	a0,-40(s0)
    dirent_t* dentry = sysfile_testfd(__path);
    80208232:	fd843503          	ld	a0,-40(s0)
    80208236:	fffff097          	auipc	ra,0xfffff
    8020823a:	7e0080e7          	jalr	2016(ra) # 80207a16 <sysfile_testfd>
    8020823e:	fea43423          	sd	a0,-24(s0)
    if (dentry == NULL)
    80208242:	fe843783          	ld	a5,-24(s0)
    80208246:	e399                	bnez	a5,8020824c <sysfile_chdir+0x26>
        return -E_NO_DEV;
    80208248:	57cd                	li	a5,-13
    8020824a:	a091                	j	8020828e <sysfile_chdir+0x68>
    dirent_t* cwd = getCurrentProc()->cwd;
    8020824c:	ffffa097          	auipc	ra,0xffffa
    80208250:	982080e7          	jalr	-1662(ra) # 80201bce <getCurrentProc>
    80208254:	87aa                	mv	a5,a0
    80208256:	7bdc                	ld	a5,176(a5)
    80208258:	fef43023          	sd	a5,-32(s0)
    if (!(dentry->d_type & ATTR_DIRECTORY))
    8020825c:	fe843783          	ld	a5,-24(s0)
    80208260:	0147c783          	lbu	a5,20(a5)
    80208264:	2781                	sext.w	a5,a5
    80208266:	8bc1                	andi	a5,a5,16
    80208268:	2781                	sext.w	a5,a5
    8020826a:	e399                	bnez	a5,80208270 <sysfile_chdir+0x4a>
        return -1;  // TODO
    8020826c:	57fd                	li	a5,-1
    8020826e:	a005                	j	8020828e <sysfile_chdir+0x68>
    __fat32_put(cwd);
    80208270:	fe043503          	ld	a0,-32(s0)
    80208274:	ffffe097          	auipc	ra,0xffffe
    80208278:	51a080e7          	jalr	1306(ra) # 8020678e <__fat32_put>
    getCurrentProc()->cwd = dentry;
    8020827c:	ffffa097          	auipc	ra,0xffffa
    80208280:	952080e7          	jalr	-1710(ra) # 80201bce <getCurrentProc>
    80208284:	872a                	mv	a4,a0
    80208286:	fe843783          	ld	a5,-24(s0)
    8020828a:	fb5c                	sd	a5,176(a4)
    return 0;
    8020828c:	4781                	li	a5,0
}
    8020828e:	853e                	mv	a0,a5
    80208290:	70a2                	ld	ra,40(sp)
    80208292:	7402                	ld	s0,32(sp)
    80208294:	6145                	addi	sp,sp,48
    80208296:	8082                	ret

0000000080208298 <sysfile_mkdir>:

int
sysfile_mkdir(const char* __path, uint32_t mode) {
    80208298:	7179                	addi	sp,sp,-48
    8020829a:	f406                	sd	ra,40(sp)
    8020829c:	f022                	sd	s0,32(sp)
    8020829e:	1800                	addi	s0,sp,48
    802082a0:	fca43c23          	sd	a0,-40(s0)
    802082a4:	87ae                	mv	a5,a1
    802082a6:	fcf42a23          	sw	a5,-44(s0)
    char* path;
    copy_path(&path, __path);
    802082aa:	fe040793          	addi	a5,s0,-32
    802082ae:	fd843583          	ld	a1,-40(s0)
    802082b2:	853e                	mv	a0,a5
    802082b4:	fffff097          	auipc	ra,0xfffff
    802082b8:	6da080e7          	jalr	1754(ra) # 8020798e <copy_path>
    dirent_t* tentry = __sysfile_create(path, S_IFDIR, mode);
    802082bc:	fe043783          	ld	a5,-32(s0)
    802082c0:	fd442703          	lw	a4,-44(s0)
    802082c4:	863a                	mv	a2,a4
    802082c6:	6591                	lui	a1,0x4
    802082c8:	853e                	mv	a0,a5
    802082ca:	fffff097          	auipc	ra,0xfffff
    802082ce:	7aa080e7          	jalr	1962(ra) # 80207a74 <__sysfile_create>
    802082d2:	fea43423          	sd	a0,-24(s0)
    kmfree(path);
    802082d6:	fe043783          	ld	a5,-32(s0)
    802082da:	853e                	mv	a0,a5
    802082dc:	ffff9097          	auipc	ra,0xffff9
    802082e0:	9dc080e7          	jalr	-1572(ra) # 80200cb8 <kmfree>
    if (tentry == NULL)
    802082e4:	fe843783          	ld	a5,-24(s0)
    802082e8:	e399                	bnez	a5,802082ee <sysfile_mkdir+0x56>
        return -1;
    802082ea:	57fd                	li	a5,-1
    802082ec:	a801                	j	802082fc <sysfile_mkdir+0x64>
    __fat32_put(tentry);
    802082ee:	fe843503          	ld	a0,-24(s0)
    802082f2:	ffffe097          	auipc	ra,0xffffe
    802082f6:	49c080e7          	jalr	1180(ra) # 8020678e <__fat32_put>
    return 0;
    802082fa:	4781                	li	a5,0
}
    802082fc:	853e                	mv	a0,a5
    802082fe:	70a2                	ld	ra,40(sp)
    80208300:	7402                	ld	s0,32(sp)
    80208302:	6145                	addi	sp,sp,48
    80208304:	8082                	ret

0000000080208306 <sysfile_link>:

int
sysfile_link(const char* __path1, const char* __path2) {
    80208306:	7179                	addi	sp,sp,-48
    80208308:	f422                	sd	s0,40(sp)
    8020830a:	1800                	addi	s0,sp,48
    8020830c:	fca43c23          	sd	a0,-40(s0)
    80208310:	fcb43823          	sd	a1,-48(s0)
    return -E_UNIMP;  // TODO
    80208314:	57b1                	li	a5,-20
    }
    ret = vfs_link(oldPath, newPath);
    kmfree(newPath);
    kmfree(oldPath);
    return ret;
}
    80208316:	853e                	mv	a0,a5
    80208318:	7422                	ld	s0,40(sp)
    8020831a:	6145                	addi	sp,sp,48
    8020831c:	8082                	ret

000000008020831e <isDirEmpty>:

static int
isDirEmpty(dirent_t* dir) {
    8020831e:	7125                	addi	sp,sp,-416
    80208320:	ef06                	sd	ra,408(sp)
    80208322:	eb22                	sd	s0,400(sp)
    80208324:	1300                	addi	s0,sp,416
    80208326:	e6a43423          	sd	a0,-408(s0)
    dirent_t temp;
    int count;  // TODO占位
    temp.valid = FALSE;
    8020832a:	fc042423          	sw	zero,-56(s0)
    return __fat32_enExt(dir, &temp, 2 * sizeof(fat32Entry_t), &count) < 0;
    8020832e:	e7c40713          	addi	a4,s0,-388
    80208332:	e8040793          	addi	a5,s0,-384
    80208336:	86ba                	mv	a3,a4
    80208338:	04000613          	li	a2,64
    8020833c:	85be                	mv	a1,a5
    8020833e:	e6843503          	ld	a0,-408(s0)
    80208342:	ffffe097          	auipc	ra,0xffffe
    80208346:	23c080e7          	jalr	572(ra) # 8020657e <__fat32_enExt>
    8020834a:	87aa                	mv	a5,a0
    8020834c:	01f7d79b          	srliw	a5,a5,0x1f
    80208350:	0ff7f793          	zext.b	a5,a5
    80208354:	2781                	sext.w	a5,a5
}
    80208356:	853e                	mv	a0,a5
    80208358:	60fa                	ld	ra,408(sp)
    8020835a:	645a                	ld	s0,400(sp)
    8020835c:	611d                	addi	sp,sp,416
    8020835e:	8082                	ret

0000000080208360 <sysfile_rename>:

int
sysfile_rename(const char* __path1, const char* __path2) {  // TODO实现逻辑？
    80208360:	7159                	addi	sp,sp,-112
    80208362:	f486                	sd	ra,104(sp)
    80208364:	f0a2                	sd	s0,96(sp)
    80208366:	1880                	addi	s0,sp,112
    80208368:	f8a43c23          	sd	a0,-104(s0)
    8020836c:	f8b43823          	sd	a1,-112(s0)
    char *oldPath, *newPath;
    int ret = copy_path(&oldPath, __path1);
    80208370:	fb840793          	addi	a5,s0,-72
    80208374:	f9843583          	ld	a1,-104(s0)
    80208378:	853e                	mv	a0,a5
    8020837a:	fffff097          	auipc	ra,0xfffff
    8020837e:	614080e7          	jalr	1556(ra) # 8020798e <copy_path>
    80208382:	87aa                	mv	a5,a0
    80208384:	fef42623          	sw	a5,-20(s0)
    if (ret < 0)
    80208388:	fec42783          	lw	a5,-20(s0)
    8020838c:	2781                	sext.w	a5,a5
    8020838e:	0007d563          	bgez	a5,80208398 <sysfile_rename+0x38>
        return ret;
    80208392:	fec42783          	lw	a5,-20(s0)
    80208396:	ac31                	j	802085b2 <sysfile_rename+0x252>
    ret = copy_path(&newPath, __path2);
    80208398:	fb040793          	addi	a5,s0,-80
    8020839c:	f9043583          	ld	a1,-112(s0)
    802083a0:	853e                	mv	a0,a5
    802083a2:	fffff097          	auipc	ra,0xfffff
    802083a6:	5ec080e7          	jalr	1516(ra) # 8020798e <copy_path>
    802083aa:	87aa                	mv	a5,a0
    802083ac:	fef42623          	sw	a5,-20(s0)
    if (ret < 0) {
    802083b0:	fec42783          	lw	a5,-20(s0)
    802083b4:	2781                	sext.w	a5,a5
    802083b6:	0007dc63          	bgez	a5,802083ce <sysfile_rename+0x6e>
        kmfree(oldPath);
    802083ba:	fb843783          	ld	a5,-72(s0)
    802083be:	853e                	mv	a0,a5
    802083c0:	ffff9097          	auipc	ra,0xffff9
    802083c4:	8f8080e7          	jalr	-1800(ra) # 80200cb8 <kmfree>
        return ret;
    802083c8:	fec42783          	lw	a5,-20(s0)
    802083cc:	a2dd                	j	802085b2 <sysfile_rename+0x252>
    }
    char* name = formatName(oldPath);
    802083ce:	fb843783          	ld	a5,-72(s0)
    802083d2:	853e                	mv	a0,a5
    802083d4:	ffffd097          	auipc	ra,0xffffd
    802083d8:	1e8080e7          	jalr	488(ra) # 802055bc <formatName>
    802083dc:	fca43c23          	sd	a0,-40(s0)
    dirent_t *src, *dst = NULL, *psrc, *pdst;
    802083e0:	fe043023          	sd	zero,-32(s0)
    src = __fat32_name(oldPath);
    802083e4:	fb843783          	ld	a5,-72(s0)
    802083e8:	853e                	mv	a0,a5
    802083ea:	fffff097          	auipc	ra,0xfffff
    802083ee:	dee080e7          	jalr	-530(ra) # 802071d8 <__fat32_name>
    802083f2:	fca43823          	sd	a0,-48(s0)
    pdst = __fat32_nameParent(newPath, oldPath);
    802083f6:	fb043783          	ld	a5,-80(s0)
    802083fa:	fb843703          	ld	a4,-72(s0)
    802083fe:	85ba                	mv	a1,a4
    80208400:	853e                	mv	a0,a5
    80208402:	fffff097          	auipc	ra,0xfffff
    80208406:	e02080e7          	jalr	-510(ra) # 80207204 <__fat32_nameParent>
    8020840a:	fca43423          	sd	a0,-56(s0)
    if (src == NULL || pdst == NULL || name == NULL) {
    8020840e:	fd043783          	ld	a5,-48(s0)
    80208412:	c799                	beqz	a5,80208420 <sysfile_rename+0xc0>
    80208414:	fc843783          	ld	a5,-56(s0)
    80208418:	c781                	beqz	a5,80208420 <sysfile_rename+0xc0>
    8020841a:	fd843783          	ld	a5,-40(s0)
    8020841e:	e789                	bnez	a5,80208428 <sysfile_rename+0xc8>
        ret = -E_INVAL;
    80208420:	57f5                	li	a5,-3
    80208422:	fef42623          	sw	a5,-20(s0)
        goto out;
    80208426:	aa39                	j	80208544 <sysfile_rename+0x1e4>
    }
    psrc = src->parent;
    80208428:	fd043783          	ld	a5,-48(s0)
    8020842c:	1587b783          	ld	a5,344(a5)
    80208430:	fcf43023          	sd	a5,-64(s0)

    uint32_t off;
    dentry_lock(src);
    80208434:	fd043503          	ld	a0,-48(s0)
    80208438:	ffffd097          	auipc	ra,0xffffd
    8020843c:	6b2080e7          	jalr	1714(ra) # 80205aea <dentry_lock>
    dentry_lock(pdst);
    80208440:	fc843503          	ld	a0,-56(s0)
    80208444:	ffffd097          	auipc	ra,0xffffd
    80208448:	6a6080e7          	jalr	1702(ra) # 80205aea <dentry_lock>

    dst = __fat32_lookupDir(pdst, name, &off);
    8020844c:	fac40793          	addi	a5,s0,-84
    80208450:	863e                	mv	a2,a5
    80208452:	fd843583          	ld	a1,-40(s0)
    80208456:	fc843503          	ld	a0,-56(s0)
    8020845a:	ffffe097          	auipc	ra,0xffffe
    8020845e:	4c6080e7          	jalr	1222(ra) # 80206920 <__fat32_lookupDir>
    80208462:	fea43023          	sd	a0,-32(s0)
    if (dst != NULL) {
    80208466:	fe043783          	ld	a5,-32(s0)
    8020846a:	cfa1                	beqz	a5,802084c2 <sysfile_rename+0x162>
        dentry_lock(dst);
    8020846c:	fe043503          	ld	a0,-32(s0)
    80208470:	ffffd097          	auipc	ra,0xffffd
    80208474:	67a080e7          	jalr	1658(ra) # 80205aea <dentry_lock>
        if (src == dst)
    80208478:	fd043703          	ld	a4,-48(s0)
    8020847c:	fe043783          	ld	a5,-32(s0)
    80208480:	0af70d63          	beq	a4,a5,8020853a <sysfile_rename+0x1da>
            goto out;
        else if ((src->d_type & ATTR_DIRECTORY) && (dst->d_type & ATTR_DIRECTORY)) {
    80208484:	fd043783          	ld	a5,-48(s0)
    80208488:	0147c783          	lbu	a5,20(a5)
    8020848c:	2781                	sext.w	a5,a5
    8020848e:	8bc1                	andi	a5,a5,16
    80208490:	2781                	sext.w	a5,a5
    80208492:	c7d5                	beqz	a5,8020853e <sysfile_rename+0x1de>
    80208494:	fe043783          	ld	a5,-32(s0)
    80208498:	0147c783          	lbu	a5,20(a5)
    8020849c:	2781                	sext.w	a5,a5
    8020849e:	8bc1                	andi	a5,a5,16
    802084a0:	2781                	sext.w	a5,a5
    802084a2:	cfd1                	beqz	a5,8020853e <sysfile_rename+0x1de>
            if (!isDirEmpty(dst))
    802084a4:	fe043503          	ld	a0,-32(s0)
    802084a8:	00000097          	auipc	ra,0x0
    802084ac:	e76080e7          	jalr	-394(ra) # 8020831e <isDirEmpty>
    802084b0:	87aa                	mv	a5,a0
    802084b2:	cbc1                	beqz	a5,80208542 <sysfile_rename+0x1e2>
                goto out;
            else
                __fat32_remove(dst);
    802084b4:	fe043503          	ld	a0,-32(s0)
    802084b8:	ffffe097          	auipc	ra,0xffffe
    802084bc:	d44080e7          	jalr	-700(ra) # 802061fc <__fat32_remove>
            if (!isDirEmpty(dst))
    802084c0:	0001                	nop
        } else
            goto out;
    }

    memmove(src->d_name, name, FAT32_MAX_FILENAME);
    802084c2:	fd043783          	ld	a5,-48(s0)
    802084c6:	07d5                	addi	a5,a5,21
    802084c8:	0ff00613          	li	a2,255
    802084cc:	fd843583          	ld	a1,-40(s0)
    802084d0:	853e                	mv	a0,a5
    802084d2:	ffffa097          	auipc	ra,0xffffa
    802084d6:	6aa080e7          	jalr	1706(ra) # 80202b7c <memmove>
    __fat32_create(pdst, src, off);
    802084da:	fac42783          	lw	a5,-84(s0)
    802084de:	863e                	mv	a2,a5
    802084e0:	fd043583          	ld	a1,-48(s0)
    802084e4:	fc843503          	ld	a0,-56(s0)
    802084e8:	ffffe097          	auipc	ra,0xffffe
    802084ec:	7ee080e7          	jalr	2030(ra) # 80206cd6 <__fat32_create>
    __fat32_remove(src);
    802084f0:	fd043503          	ld	a0,-48(s0)
    802084f4:	ffffe097          	auipc	ra,0xffffe
    802084f8:	d08080e7          	jalr	-760(ra) # 802061fc <__fat32_remove>
    src->parent = __fat32_dup(pdst);
    802084fc:	fc843503          	ld	a0,-56(s0)
    80208500:	ffffe097          	auipc	ra,0xffffe
    80208504:	ae4080e7          	jalr	-1308(ra) # 80205fe4 <__fat32_dup>
    80208508:	872a                	mv	a4,a0
    8020850a:	fd043783          	ld	a5,-48(s0)
    8020850e:	14e7bc23          	sd	a4,344(a5)
    src->d_off = off;
    80208512:	fac42783          	lw	a5,-84(s0)
    80208516:	02079713          	slli	a4,a5,0x20
    8020851a:	9301                	srli	a4,a4,0x20
    8020851c:	fd043783          	ld	a5,-48(s0)
    80208520:	e798                	sd	a4,8(a5)
    src->valid = TRUE;
    80208522:	fd043783          	ld	a5,-48(s0)
    80208526:	4705                	li	a4,1
    80208528:	14e7a423          	sw	a4,328(a5)
    __fat32_put(psrc);
    8020852c:	fc043503          	ld	a0,-64(s0)
    80208530:	ffffe097          	auipc	ra,0xffffe
    80208534:	25e080e7          	jalr	606(ra) # 8020678e <__fat32_put>
    80208538:	a031                	j	80208544 <sysfile_rename+0x1e4>
            goto out;
    8020853a:	0001                	nop
    8020853c:	a021                	j	80208544 <sysfile_rename+0x1e4>
            goto out;
    8020853e:	0001                	nop
    80208540:	a011                	j	80208544 <sysfile_rename+0x1e4>
                goto out;
    80208542:	0001                	nop

out:

    if (dst != NULL) {
    80208544:	fe043783          	ld	a5,-32(s0)
    80208548:	cf89                	beqz	a5,80208562 <sysfile_rename+0x202>
        __fat32_put(dst);
    8020854a:	fe043503          	ld	a0,-32(s0)
    8020854e:	ffffe097          	auipc	ra,0xffffe
    80208552:	240080e7          	jalr	576(ra) # 8020678e <__fat32_put>
        dentry_unlock(dst);
    80208556:	fe043503          	ld	a0,-32(s0)
    8020855a:	ffffd097          	auipc	ra,0xffffd
    8020855e:	5d8080e7          	jalr	1496(ra) # 80205b32 <dentry_unlock>
    }
    __fat32_put(pdst);
    80208562:	fc843503          	ld	a0,-56(s0)
    80208566:	ffffe097          	auipc	ra,0xffffe
    8020856a:	228080e7          	jalr	552(ra) # 8020678e <__fat32_put>
    dentry_unlock(pdst);
    8020856e:	fc843503          	ld	a0,-56(s0)
    80208572:	ffffd097          	auipc	ra,0xffffd
    80208576:	5c0080e7          	jalr	1472(ra) # 80205b32 <dentry_unlock>
    __fat32_put(src);
    8020857a:	fd043503          	ld	a0,-48(s0)
    8020857e:	ffffe097          	auipc	ra,0xffffe
    80208582:	210080e7          	jalr	528(ra) # 8020678e <__fat32_put>
    dentry_unlock(src);
    80208586:	fd043503          	ld	a0,-48(s0)
    8020858a:	ffffd097          	auipc	ra,0xffffd
    8020858e:	5a8080e7          	jalr	1448(ra) # 80205b32 <dentry_unlock>

    kmfree(newPath);
    80208592:	fb043783          	ld	a5,-80(s0)
    80208596:	853e                	mv	a0,a5
    80208598:	ffff8097          	auipc	ra,0xffff8
    8020859c:	720080e7          	jalr	1824(ra) # 80200cb8 <kmfree>
    kmfree(oldPath);
    802085a0:	fb843783          	ld	a5,-72(s0)
    802085a4:	853e                	mv	a0,a5
    802085a6:	ffff8097          	auipc	ra,0xffff8
    802085aa:	712080e7          	jalr	1810(ra) # 80200cb8 <kmfree>
    return ret;  // TODO
    802085ae:	fec42783          	lw	a5,-20(s0)
}
    802085b2:	853e                	mv	a0,a5
    802085b4:	70a6                	ld	ra,104(sp)
    802085b6:	7406                	ld	s0,96(sp)
    802085b8:	6165                	addi	sp,sp,112
    802085ba:	8082                	ret

00000000802085bc <sysfile_getcwd>:

char*
sysfile_getcwd(char* buf, size_t len) {
    802085bc:	7169                	addi	sp,sp,-304
    802085be:	f606                	sd	ra,296(sp)
    802085c0:	f222                	sd	s0,288(sp)
    802085c2:	1a00                	addi	s0,sp,304
    802085c4:	eca43c23          	sd	a0,-296(s0)
    802085c8:	ecb43823          	sd	a1,-304(s0)
    // int ret;
    dirent_t* dentry = getCurrentProc()->cwd;
    802085cc:	ffff9097          	auipc	ra,0xffff9
    802085d0:	602080e7          	jalr	1538(ra) # 80201bce <getCurrentProc>
    802085d4:	87aa                	mv	a5,a0
    802085d6:	7bdc                	ld	a5,176(a5)
    802085d8:	fef43423          	sd	a5,-24(s0)
    char path[FAT32_MAX_PATH];
    char* s;
    if (dentry->parent == NULL) {
    802085dc:	fe843783          	ld	a5,-24(s0)
    802085e0:	1587b783          	ld	a5,344(a5)
    802085e4:	eb81                	bnez	a5,802085f4 <sysfile_getcwd+0x38>
        s = "/";
    802085e6:	00003797          	auipc	a5,0x3
    802085ea:	19278793          	addi	a5,a5,402 # 8020b778 <illegal+0x1b8>
    802085ee:	fef43023          	sd	a5,-32(s0)
    802085f2:	a859                	j	80208688 <sysfile_getcwd+0xcc>
    } else {
        s = path + FAT32_MAX_PATH - 1;
    802085f4:	ee040793          	addi	a5,s0,-288
    802085f8:	0fe78793          	addi	a5,a5,254
    802085fc:	fef43023          	sd	a5,-32(s0)
        *s = '\0';
    80208600:	fe043783          	ld	a5,-32(s0)
    80208604:	00078023          	sb	zero,0(a5)
        while (dentry->parent) {
    80208608:	a89d                	j	8020867e <sysfile_getcwd+0xc2>
            len = strlen(dentry->d_name);
    8020860a:	fe843783          	ld	a5,-24(s0)
    8020860e:	07d5                	addi	a5,a5,21
    80208610:	853e                	mv	a0,a5
    80208612:	ffffb097          	auipc	ra,0xffffb
    80208616:	85a080e7          	jalr	-1958(ra) # 80202e6c <strlen>
    8020861a:	eca43823          	sd	a0,-304(s0)
            s -= len;
    8020861e:	ed043783          	ld	a5,-304(s0)
    80208622:	40f007b3          	neg	a5,a5
    80208626:	fe043703          	ld	a4,-32(s0)
    8020862a:	97ba                	add	a5,a5,a4
    8020862c:	fef43023          	sd	a5,-32(s0)
            if (s <= path)  // can't reach root "/"
    80208630:	ee040793          	addi	a5,s0,-288
    80208634:	fe043703          	ld	a4,-32(s0)
    80208638:	00e7e463          	bltu	a5,a4,80208640 <sysfile_getcwd+0x84>
                return NULL;
    8020863c:	4781                	li	a5,0
    8020863e:	a88d                	j	802086b0 <sysfile_getcwd+0xf4>
            strncpy(buf, dentry->d_name, len);
    80208640:	fe843783          	ld	a5,-24(s0)
    80208644:	07d5                	addi	a5,a5,21
    80208646:	ed043703          	ld	a4,-304(s0)
    8020864a:	2701                	sext.w	a4,a4
    8020864c:	863a                	mv	a2,a4
    8020864e:	85be                	mv	a1,a5
    80208650:	ed843503          	ld	a0,-296(s0)
    80208654:	ffffa097          	auipc	ra,0xffffa
    80208658:	746080e7          	jalr	1862(ra) # 80202d9a <strncpy>
            --s;
    8020865c:	fe043783          	ld	a5,-32(s0)
    80208660:	17fd                	addi	a5,a5,-1
    80208662:	fef43023          	sd	a5,-32(s0)
            *s = '/';
    80208666:	fe043783          	ld	a5,-32(s0)
    8020866a:	02f00713          	li	a4,47
    8020866e:	00e78023          	sb	a4,0(a5)
            dentry = dentry->parent;
    80208672:	fe843783          	ld	a5,-24(s0)
    80208676:	1587b783          	ld	a5,344(a5)
    8020867a:	fef43423          	sd	a5,-24(s0)
        while (dentry->parent) {
    8020867e:	fe843783          	ld	a5,-24(s0)
    80208682:	1587b783          	ld	a5,344(a5)
    80208686:	f3d1                	bnez	a5,8020860a <sysfile_getcwd+0x4e>
        }
    }
    memcpy(buf, s, strlen(s) + 1);
    80208688:	fe043503          	ld	a0,-32(s0)
    8020868c:	ffffa097          	auipc	ra,0xffffa
    80208690:	7e0080e7          	jalr	2016(ra) # 80202e6c <strlen>
    80208694:	87aa                	mv	a5,a0
    80208696:	0785                	addi	a5,a5,1
    80208698:	863e                	mv	a2,a5
    8020869a:	fe043583          	ld	a1,-32(s0)
    8020869e:	ed843503          	ld	a0,-296(s0)
    802086a2:	ffffa097          	auipc	ra,0xffffa
    802086a6:	53a080e7          	jalr	1338(ra) # 80202bdc <memcpy>
    return dentry->d_name;
    802086aa:	fe843783          	ld	a5,-24(s0)
    802086ae:	07d5                	addi	a5,a5,21
}
    802086b0:	853e                	mv	a0,a5
    802086b2:	70b2                	ld	ra,296(sp)
    802086b4:	7412                	ld	s0,288(sp)
    802086b6:	6155                	addi	sp,sp,304
    802086b8:	8082                	ret

00000000802086ba <sysfile_getDirEntry>:

int
sysfile_getDirEntry(int fd, dirent_t* __direntp) {  // TODO?
    802086ba:	7179                	addi	sp,sp,-48
    802086bc:	f406                	sd	ra,40(sp)
    802086be:	f022                	sd	s0,32(sp)
    802086c0:	1800                	addi	s0,sp,48
    802086c2:	87aa                	mv	a5,a0
    802086c4:	fcb43823          	sd	a1,-48(s0)
    802086c8:	fcf42e23          	sw	a5,-36(s0)
    file_t* f = getCurrentProc()->openFiles[fd];
    802086cc:	ffff9097          	auipc	ra,0xffff9
    802086d0:	502080e7          	jalr	1282(ra) # 80201bce <getCurrentProc>
    802086d4:	872a                	mv	a4,a0
    802086d6:	fdc42783          	lw	a5,-36(s0)
    802086da:	07d9                	addi	a5,a5,22
    802086dc:	078e                	slli	a5,a5,0x3
    802086de:	97ba                	add	a5,a5,a4
    802086e0:	679c                	ld	a5,8(a5)
    802086e2:	fef43423          	sd	a5,-24(s0)
    if (f == NULL || f->openCount == 0)
    802086e6:	fe843783          	ld	a5,-24(s0)
    802086ea:	c789                	beqz	a5,802086f4 <sysfile_getDirEntry+0x3a>
    802086ec:	fe843783          	ld	a5,-24(s0)
    802086f0:	5b9c                	lw	a5,48(a5)
    802086f2:	e399                	bnez	a5,802086f8 <sysfile_getDirEntry+0x3e>
        return -E_INVAL;
    802086f4:	57f5                	li	a5,-3
    802086f6:	a015                	j	8020871a <sysfile_getDirEntry+0x60>
    dirent_t* dentry = f->d_entry;
    802086f8:	fe843783          	ld	a5,-24(s0)
    802086fc:	779c                	ld	a5,40(a5)
    802086fe:	fef43023          	sd	a5,-32(s0)
    memcpy(__direntp, dentry, sizeof(dirent_t));
    80208702:	17000613          	li	a2,368
    80208706:	fe043583          	ld	a1,-32(s0)
    8020870a:	fd043503          	ld	a0,-48(s0)
    8020870e:	ffffa097          	auipc	ra,0xffffa
    80208712:	4ce080e7          	jalr	1230(ra) # 80202bdc <memcpy>

    return sizeof(dirent_t);
    80208716:	17000793          	li	a5,368
}
    8020871a:	853e                	mv	a0,a5
    8020871c:	70a2                	ld	ra,40(sp)
    8020871e:	7402                	ld	s0,32(sp)
    80208720:	6145                	addi	sp,sp,48
    80208722:	8082                	ret

0000000080208724 <sysfile_dup>:

int
sysfile_dup(int fd) {
    80208724:	7179                	addi	sp,sp,-48
    80208726:	f406                	sd	ra,40(sp)
    80208728:	f022                	sd	s0,32(sp)
    8020872a:	1800                	addi	s0,sp,48
    8020872c:	87aa                	mv	a5,a0
    8020872e:	fcf42e23          	sw	a5,-36(s0)
    spinlock_acquire(&getCurrentProc()->lk);
    80208732:	ffff9097          	auipc	ra,0xffff9
    80208736:	49c080e7          	jalr	1180(ra) # 80201bce <getCurrentProc>
    8020873a:	87aa                	mv	a5,a0
    8020873c:	56878793          	addi	a5,a5,1384
    80208740:	853e                	mv	a0,a5
    80208742:	ffffc097          	auipc	ra,0xffffc
    80208746:	210080e7          	jalr	528(ra) # 80204952 <spinlock_acquire>
    file_t* f = getCurrentProc()->openFiles[fd];
    8020874a:	ffff9097          	auipc	ra,0xffff9
    8020874e:	484080e7          	jalr	1156(ra) # 80201bce <getCurrentProc>
    80208752:	872a                	mv	a4,a0
    80208754:	fdc42783          	lw	a5,-36(s0)
    80208758:	07d9                	addi	a5,a5,22
    8020875a:	078e                	slli	a5,a5,0x3
    8020875c:	97ba                	add	a5,a5,a4
    8020875e:	679c                	ld	a5,8(a5)
    80208760:	fef43423          	sd	a5,-24(s0)
    if (f == NULL || f->openCount == 0)
    80208764:	fe843783          	ld	a5,-24(s0)
    80208768:	cbb9                	beqz	a5,802087be <sysfile_dup+0x9a>
    8020876a:	fe843783          	ld	a5,-24(s0)
    8020876e:	5b9c                	lw	a5,48(a5)
    80208770:	c7b9                	beqz	a5,802087be <sysfile_dup+0x9a>
        goto fail;
    int fdNew = __fd_alloc(f);
    80208772:	fe843503          	ld	a0,-24(s0)
    80208776:	fffff097          	auipc	ra,0xfffff
    8020877a:	f76080e7          	jalr	-138(ra) # 802076ec <__fd_alloc>
    8020877e:	87aa                	mv	a5,a0
    80208780:	fef42223          	sw	a5,-28(s0)
    if (fdNew < 0)
    80208784:	fe442783          	lw	a5,-28(s0)
    80208788:	2781                	sext.w	a5,a5
    8020878a:	0207cc63          	bltz	a5,802087c2 <sysfile_dup+0x9e>
        goto fail;
    ++f->openCount;
    8020878e:	fe843783          	ld	a5,-24(s0)
    80208792:	5b9c                	lw	a5,48(a5)
    80208794:	2785                	addiw	a5,a5,1
    80208796:	0007871b          	sext.w	a4,a5
    8020879a:	fe843783          	ld	a5,-24(s0)
    8020879e:	db98                	sw	a4,48(a5)
    spinlock_release(&getCurrentProc()->lk);
    802087a0:	ffff9097          	auipc	ra,0xffff9
    802087a4:	42e080e7          	jalr	1070(ra) # 80201bce <getCurrentProc>
    802087a8:	87aa                	mv	a5,a0
    802087aa:	56878793          	addi	a5,a5,1384
    802087ae:	853e                	mv	a0,a5
    802087b0:	ffffc097          	auipc	ra,0xffffc
    802087b4:	218080e7          	jalr	536(ra) # 802049c8 <spinlock_release>
    return fdNew;
    802087b8:	fe442783          	lw	a5,-28(s0)
    802087bc:	a00d                	j	802087de <sysfile_dup+0xba>
        goto fail;
    802087be:	0001                	nop
    802087c0:	a011                	j	802087c4 <sysfile_dup+0xa0>
        goto fail;
    802087c2:	0001                	nop

fail:
    spinlock_release(&getCurrentProc()->lk);
    802087c4:	ffff9097          	auipc	ra,0xffff9
    802087c8:	40a080e7          	jalr	1034(ra) # 80201bce <getCurrentProc>
    802087cc:	87aa                	mv	a5,a0
    802087ce:	56878793          	addi	a5,a5,1384
    802087d2:	853e                	mv	a0,a5
    802087d4:	ffffc097          	auipc	ra,0xffffc
    802087d8:	1f4080e7          	jalr	500(ra) # 802049c8 <spinlock_release>
    return -E_INVAL;
    802087dc:	57f5                	li	a5,-3
}
    802087de:	853e                	mv	a0,a5
    802087e0:	70a2                	ld	ra,40(sp)
    802087e2:	7402                	ld	s0,32(sp)
    802087e4:	6145                	addi	sp,sp,48
    802087e6:	8082                	ret

00000000802087e8 <sysfile_dup2>:

int
sysfile_dup2(int fd_old, int fd_new) {
    802087e8:	7179                	addi	sp,sp,-48
    802087ea:	f406                	sd	ra,40(sp)
    802087ec:	f022                	sd	s0,32(sp)
    802087ee:	1800                	addi	s0,sp,48
    802087f0:	87aa                	mv	a5,a0
    802087f2:	872e                	mv	a4,a1
    802087f4:	fcf42e23          	sw	a5,-36(s0)
    802087f8:	87ba                	mv	a5,a4
    802087fa:	fcf42c23          	sw	a5,-40(s0)
    spinlock_acquire(&getCurrentProc()->lk);
    802087fe:	ffff9097          	auipc	ra,0xffff9
    80208802:	3d0080e7          	jalr	976(ra) # 80201bce <getCurrentProc>
    80208806:	87aa                	mv	a5,a0
    80208808:	56878793          	addi	a5,a5,1384
    8020880c:	853e                	mv	a0,a5
    8020880e:	ffffc097          	auipc	ra,0xffffc
    80208812:	144080e7          	jalr	324(ra) # 80204952 <spinlock_acquire>

    file_t* f = getCurrentProc()->openFiles[fd_old];
    80208816:	ffff9097          	auipc	ra,0xffff9
    8020881a:	3b8080e7          	jalr	952(ra) # 80201bce <getCurrentProc>
    8020881e:	872a                	mv	a4,a0
    80208820:	fdc42783          	lw	a5,-36(s0)
    80208824:	07d9                	addi	a5,a5,22
    80208826:	078e                	slli	a5,a5,0x3
    80208828:	97ba                	add	a5,a5,a4
    8020882a:	679c                	ld	a5,8(a5)
    8020882c:	fef43423          	sd	a5,-24(s0)
    if (f == NULL || f->openCount == 0)
    80208830:	fe843783          	ld	a5,-24(s0)
    80208834:	cfb5                	beqz	a5,802088b0 <sysfile_dup2+0xc8>
    80208836:	fe843783          	ld	a5,-24(s0)
    8020883a:	5b9c                	lw	a5,48(a5)
    8020883c:	cbb5                	beqz	a5,802088b0 <sysfile_dup2+0xc8>
        goto fail;
    if (fd_new >= N_OPEN_FILE || getCurrentProc()->openFiles[fd_new] != NULL)
    8020883e:	fd842783          	lw	a5,-40(s0)
    80208842:	0007871b          	sext.w	a4,a5
    80208846:	09500793          	li	a5,149
    8020884a:	06e7c563          	blt	a5,a4,802088b4 <sysfile_dup2+0xcc>
    8020884e:	ffff9097          	auipc	ra,0xffff9
    80208852:	380080e7          	jalr	896(ra) # 80201bce <getCurrentProc>
    80208856:	872a                	mv	a4,a0
    80208858:	fd842783          	lw	a5,-40(s0)
    8020885c:	07d9                	addi	a5,a5,22
    8020885e:	078e                	slli	a5,a5,0x3
    80208860:	97ba                	add	a5,a5,a4
    80208862:	679c                	ld	a5,8(a5)
    80208864:	eba1                	bnez	a5,802088b4 <sysfile_dup2+0xcc>
        goto fail;
    getCurrentProc()->openFiles[fd_new] = f;
    80208866:	ffff9097          	auipc	ra,0xffff9
    8020886a:	368080e7          	jalr	872(ra) # 80201bce <getCurrentProc>
    8020886e:	872a                	mv	a4,a0
    80208870:	fd842783          	lw	a5,-40(s0)
    80208874:	07d9                	addi	a5,a5,22
    80208876:	078e                	slli	a5,a5,0x3
    80208878:	97ba                	add	a5,a5,a4
    8020887a:	fe843703          	ld	a4,-24(s0)
    8020887e:	e798                	sd	a4,8(a5)
    ++f->openCount;
    80208880:	fe843783          	ld	a5,-24(s0)
    80208884:	5b9c                	lw	a5,48(a5)
    80208886:	2785                	addiw	a5,a5,1
    80208888:	0007871b          	sext.w	a4,a5
    8020888c:	fe843783          	ld	a5,-24(s0)
    80208890:	db98                	sw	a4,48(a5)
    spinlock_release(&getCurrentProc()->lk);
    80208892:	ffff9097          	auipc	ra,0xffff9
    80208896:	33c080e7          	jalr	828(ra) # 80201bce <getCurrentProc>
    8020889a:	87aa                	mv	a5,a0
    8020889c:	56878793          	addi	a5,a5,1384
    802088a0:	853e                	mv	a0,a5
    802088a2:	ffffc097          	auipc	ra,0xffffc
    802088a6:	126080e7          	jalr	294(ra) # 802049c8 <spinlock_release>
    return fd_new;
    802088aa:	fd842783          	lw	a5,-40(s0)
    802088ae:	a00d                	j	802088d0 <sysfile_dup2+0xe8>
        goto fail;
    802088b0:	0001                	nop
    802088b2:	a011                	j	802088b6 <sysfile_dup2+0xce>
        goto fail;
    802088b4:	0001                	nop

fail:
    spinlock_release(&getCurrentProc()->lk);
    802088b6:	ffff9097          	auipc	ra,0xffff9
    802088ba:	318080e7          	jalr	792(ra) # 80201bce <getCurrentProc>
    802088be:	87aa                	mv	a5,a0
    802088c0:	56878793          	addi	a5,a5,1384
    802088c4:	853e                	mv	a0,a5
    802088c6:	ffffc097          	auipc	ra,0xffffc
    802088ca:	102080e7          	jalr	258(ra) # 802049c8 <spinlock_release>
    return -E_INVAL;
    802088ce:	57f5                	li	a5,-3
}
    802088d0:	853e                	mv	a0,a5
    802088d2:	70a2                	ld	ra,40(sp)
    802088d4:	7402                	ld	s0,32(sp)
    802088d6:	6145                	addi	sp,sp,48
    802088d8:	8082                	ret

00000000802088da <sysfile_pipe>:

int
sysfile_pipe(int* fd_store) {
    802088da:	1101                	addi	sp,sp,-32
    802088dc:	ec22                	sd	s0,24(sp)
    802088de:	1000                	addi	s0,sp,32
    802088e0:	fea43423          	sd	a0,-24(s0)
    return -E_UNIMP;  // TODO
    802088e4:	57b1                	li	a5,-20
}
    802088e6:	853e                	mv	a0,a5
    802088e8:	6462                	ld	s0,24(sp)
    802088ea:	6105                	addi	sp,sp,32
    802088ec:	8082                	ret

00000000802088ee <sysfile_mkfifo>:

int
sysfile_mkfifo(const char* __name, uint32_t flags) {
    802088ee:	1101                	addi	sp,sp,-32
    802088f0:	ec22                	sd	s0,24(sp)
    802088f2:	1000                	addi	s0,sp,32
    802088f4:	fea43423          	sd	a0,-24(s0)
    802088f8:	87ae                	mv	a5,a1
    802088fa:	fef42223          	sw	a5,-28(s0)
    return -E_UNIMP;
    802088fe:	57b1                	li	a5,-20
}
    80208900:	853e                	mv	a0,a5
    80208902:	6462                	ld	s0,24(sp)
    80208904:	6105                	addi	sp,sp,32
    80208906:	8082                	ret

0000000080208908 <sys_mount>:

int
sys_mount(const char* dev, const char* dir, const char* fsType, uint32_t flags, const void* data) {
    80208908:	7139                	addi	sp,sp,-64
    8020890a:	fc22                	sd	s0,56(sp)
    8020890c:	0080                	addi	s0,sp,64
    8020890e:	fea43423          	sd	a0,-24(s0)
    80208912:	feb43023          	sd	a1,-32(s0)
    80208916:	fcc43c23          	sd	a2,-40(s0)
    8020891a:	87b6                	mv	a5,a3
    8020891c:	fce43423          	sd	a4,-56(s0)
    80208920:	fcf42a23          	sw	a5,-44(s0)
    return -E_UNIMP;  // TODO
    80208924:	57b1                	li	a5,-20
}
    80208926:	853e                	mv	a0,a5
    80208928:	7462                	ld	s0,56(sp)
    8020892a:	6121                	addi	sp,sp,64
    8020892c:	8082                	ret

000000008020892e <sys_unmount>:

int
sys_unmount(const char* dev, uint32_t flags) {
    8020892e:	1101                	addi	sp,sp,-32
    80208930:	ec22                	sd	s0,24(sp)
    80208932:	1000                	addi	s0,sp,32
    80208934:	fea43423          	sd	a0,-24(s0)
    80208938:	87ae                	mv	a5,a1
    8020893a:	fef42223          	sw	a5,-28(s0)
    return -E_UNIMP;  // TODO
    8020893e:	57b1                	li	a5,-20
    80208940:	853e                	mv	a0,a5
    80208942:	6462                	ld	s0,24(sp)
    80208944:	6105                	addi	sp,sp,32
    80208946:	8082                	ret

0000000080208948 <virtio_disk_init>:
    // semaphore_t vdisk_lk;
    spinlock_t vdisk_lk;
} disk;

void
virtio_disk_init(void) {  // TODO 如何读写的？
    80208948:	7179                	addi	sp,sp,-48
    8020894a:	f406                	sd	ra,40(sp)
    8020894c:	f022                	sd	s0,32(sp)
    8020894e:	1800                	addi	s0,sp,48
    uint32_t status = 0;
    80208950:	fe042423          	sw	zero,-24(s0)
    spinlock_init(&disk.vdisk_lk, "virtio_disk_lk");
    80208954:	00003597          	auipc	a1,0x3
    80208958:	e2c58593          	addi	a1,a1,-468 # 8020b780 <illegal+0x1c0>
    8020895c:	00328517          	auipc	a0,0x328
    80208960:	74c50513          	addi	a0,a0,1868 # 805310a8 <disk+0x20a8>
    80208964:	ffffc097          	auipc	ra,0xffffc
    80208968:	fbe080e7          	jalr	-66(ra) # 80204922 <spinlock_init>

    if ((uint32_t)REGISTER(VIRTIO_MMIO_MAGIC_VALUE) != 0x74726976 || (uint32_t)REGISTER(VIRTIO_MMIO_VERSION) != 1 ||
    8020896c:	03f107b7          	lui	a5,0x3f10
    80208970:	0785                	addi	a5,a5,1 # 3f10001 <_entry-0x7c2effff>
    80208972:	07b2                	slli	a5,a5,0xc
    80208974:	439c                	lw	a5,0(a5)
    80208976:	2781                	sext.w	a5,a5
    80208978:	873e                	mv	a4,a5
    8020897a:	747277b7          	lui	a5,0x74727
    8020897e:	97678793          	addi	a5,a5,-1674 # 74726976 <_entry-0xbad968a>
    80208982:	04f71663          	bne	a4,a5,802089ce <virtio_disk_init+0x86>
    80208986:	00003797          	auipc	a5,0x3
    8020898a:	ed278793          	addi	a5,a5,-302 # 8020b858 <illegal+0x298>
    8020898e:	639c                	ld	a5,0(a5)
    80208990:	439c                	lw	a5,0(a5)
    80208992:	2781                	sext.w	a5,a5
    80208994:	873e                	mv	a4,a5
    80208996:	4785                	li	a5,1
    80208998:	02f71b63          	bne	a4,a5,802089ce <virtio_disk_init+0x86>
        (uint32_t)REGISTER(VIRTIO_MMIO_DEVICE_ID) != 2 || (uint32_t)REGISTER(VIRTIO_MMIO_VENDOR_ID) != 0x554d4551)
    8020899c:	00003797          	auipc	a5,0x3
    802089a0:	ec478793          	addi	a5,a5,-316 # 8020b860 <illegal+0x2a0>
    802089a4:	639c                	ld	a5,0(a5)
    802089a6:	439c                	lw	a5,0(a5)
    802089a8:	2781                	sext.w	a5,a5
    if ((uint32_t)REGISTER(VIRTIO_MMIO_MAGIC_VALUE) != 0x74726976 || (uint32_t)REGISTER(VIRTIO_MMIO_VERSION) != 1 ||
    802089aa:	873e                	mv	a4,a5
    802089ac:	4789                	li	a5,2
    802089ae:	02f71063          	bne	a4,a5,802089ce <virtio_disk_init+0x86>
        (uint32_t)REGISTER(VIRTIO_MMIO_DEVICE_ID) != 2 || (uint32_t)REGISTER(VIRTIO_MMIO_VENDOR_ID) != 0x554d4551)
    802089b2:	00003797          	auipc	a5,0x3
    802089b6:	eb678793          	addi	a5,a5,-330 # 8020b868 <illegal+0x2a8>
    802089ba:	639c                	ld	a5,0(a5)
    802089bc:	439c                	lw	a5,0(a5)
    802089be:	2781                	sext.w	a5,a5
    802089c0:	873e                	mv	a4,a5
    802089c2:	554d47b7          	lui	a5,0x554d4
    802089c6:	55178793          	addi	a5,a5,1361 # 554d4551 <_entry-0x2ad2baaf>
    802089ca:	00f70a63          	beq	a4,a5,802089de <virtio_disk_init+0x96>
        panic("could not find virtio disk");
    802089ce:	00003517          	auipc	a0,0x3
    802089d2:	dc250513          	addi	a0,a0,-574 # 8020b790 <illegal+0x1d0>
    802089d6:	ffffa097          	auipc	ra,0xffffa
    802089da:	12e080e7          	jalr	302(ra) # 80202b04 <panic>

    status |= VIRTIO_CONFIG_S_ACKNOWLEDGE;
    802089de:	fe842783          	lw	a5,-24(s0)
    802089e2:	0017e793          	ori	a5,a5,1
    802089e6:	fef42423          	sw	a5,-24(s0)
    REGISTER(VIRTIO_MMIO_STATUS) = status;
    802089ea:	00003797          	auipc	a5,0x3
    802089ee:	e8678793          	addi	a5,a5,-378 # 8020b870 <illegal+0x2b0>
    802089f2:	639c                	ld	a5,0(a5)
    802089f4:	fe842703          	lw	a4,-24(s0)
    802089f8:	c398                	sw	a4,0(a5)
    status |= VIRTIO_CONFIG_S_DRIVER;
    802089fa:	fe842783          	lw	a5,-24(s0)
    802089fe:	0027e793          	ori	a5,a5,2
    80208a02:	fef42423          	sw	a5,-24(s0)
    REGISTER(VIRTIO_MMIO_STATUS) = status;
    80208a06:	00003797          	auipc	a5,0x3
    80208a0a:	e6a78793          	addi	a5,a5,-406 # 8020b870 <illegal+0x2b0>
    80208a0e:	639c                	ld	a5,0(a5)
    80208a10:	fe842703          	lw	a4,-24(s0)
    80208a14:	c398                	sw	a4,0(a5)

    uint64_t feature = REGISTER(VIRTIO_MMIO_DEVICE_FEATURES);
    80208a16:	00003797          	auipc	a5,0x3
    80208a1a:	e6278793          	addi	a5,a5,-414 # 8020b878 <illegal+0x2b8>
    80208a1e:	639c                	ld	a5,0(a5)
    80208a20:	439c                	lw	a5,0(a5)
    80208a22:	2781                	sext.w	a5,a5
    80208a24:	1782                	slli	a5,a5,0x20
    80208a26:	9381                	srli	a5,a5,0x20
    80208a28:	fef43023          	sd	a5,-32(s0)
    feature &= ~(1 << VIRTIO_BLK_F_RO);
    80208a2c:	fe043783          	ld	a5,-32(s0)
    80208a30:	fdf7f793          	andi	a5,a5,-33
    80208a34:	fef43023          	sd	a5,-32(s0)
    feature &= ~(1 << VIRTIO_BLK_F_SCSI);
    80208a38:	fe043783          	ld	a5,-32(s0)
    80208a3c:	f7f7f793          	andi	a5,a5,-129
    80208a40:	fef43023          	sd	a5,-32(s0)
    feature &= ~(1 << VIRTIO_BLK_F_CONFIG_WCE);
    80208a44:	fe043703          	ld	a4,-32(s0)
    80208a48:	77fd                	lui	a5,0xfffff
    80208a4a:	7ff78793          	addi	a5,a5,2047 # fffffffffffff7ff <kernel_end+0xffffffff7facd7ff>
    80208a4e:	8ff9                	and	a5,a5,a4
    80208a50:	fef43023          	sd	a5,-32(s0)
    feature &= ~(1 << VIRTIO_BLK_F_MQ);
    80208a54:	fe043703          	ld	a4,-32(s0)
    80208a58:	77fd                	lui	a5,0xfffff
    80208a5a:	17fd                	addi	a5,a5,-1 # ffffffffffffefff <kernel_end+0xffffffff7faccfff>
    80208a5c:	8ff9                	and	a5,a5,a4
    80208a5e:	fef43023          	sd	a5,-32(s0)
    feature &= ~(1 << VIRTIO_F_ANY_LAYOUT);
    80208a62:	fe043703          	ld	a4,-32(s0)
    80208a66:	f80007b7          	lui	a5,0xf8000
    80208a6a:	17fd                	addi	a5,a5,-1 # fffffffff7ffffff <kernel_end+0xffffffff77acdfff>
    80208a6c:	8ff9                	and	a5,a5,a4
    80208a6e:	fef43023          	sd	a5,-32(s0)
    feature &= ~(1 << VIRTIO_RING_F_EVENT_IDX);
    80208a72:	fe043703          	ld	a4,-32(s0)
    80208a76:	e00007b7          	lui	a5,0xe0000
    80208a7a:	17fd                	addi	a5,a5,-1 # ffffffffdfffffff <kernel_end+0xffffffff5facdfff>
    80208a7c:	8ff9                	and	a5,a5,a4
    80208a7e:	fef43023          	sd	a5,-32(s0)
    feature &= ~(1 << VIRTIO_RING_F_INDIRECT_DESC);
    80208a82:	fe043703          	ld	a4,-32(s0)
    80208a86:	f00007b7          	lui	a5,0xf0000
    80208a8a:	17fd                	addi	a5,a5,-1 # ffffffffefffffff <kernel_end+0xffffffff6facdfff>
    80208a8c:	8ff9                	and	a5,a5,a4
    80208a8e:	fef43023          	sd	a5,-32(s0)
    REGISTER(VIRTIO_MMIO_DRIVER_FEATURES) = feature;
    80208a92:	00003797          	auipc	a5,0x3
    80208a96:	dee78793          	addi	a5,a5,-530 # 8020b880 <illegal+0x2c0>
    80208a9a:	639c                	ld	a5,0(a5)
    80208a9c:	fe043703          	ld	a4,-32(s0)
    80208aa0:	2701                	sext.w	a4,a4
    80208aa2:	c398                	sw	a4,0(a5)

    status |= VIRTIO_CONFIG_S_FEATURES_OK;
    80208aa4:	fe842783          	lw	a5,-24(s0)
    80208aa8:	0087e793          	ori	a5,a5,8
    80208aac:	fef42423          	sw	a5,-24(s0)
    REGISTER(VIRTIO_MMIO_STATUS) = status;
    80208ab0:	00003797          	auipc	a5,0x3
    80208ab4:	dc078793          	addi	a5,a5,-576 # 8020b870 <illegal+0x2b0>
    80208ab8:	639c                	ld	a5,0(a5)
    80208aba:	fe842703          	lw	a4,-24(s0)
    80208abe:	c398                	sw	a4,0(a5)
    status |= VIRTIO_CONFIG_S_DRIVER_OK;
    80208ac0:	fe842783          	lw	a5,-24(s0)
    80208ac4:	0047e793          	ori	a5,a5,4
    80208ac8:	fef42423          	sw	a5,-24(s0)
    REGISTER(VIRTIO_MMIO_STATUS) = status;
    80208acc:	00003797          	auipc	a5,0x3
    80208ad0:	da478793          	addi	a5,a5,-604 # 8020b870 <illegal+0x2b0>
    80208ad4:	639c                	ld	a5,0(a5)
    80208ad6:	fe842703          	lw	a4,-24(s0)
    80208ada:	c398                	sw	a4,0(a5)
    REGISTER(VIRTIO_MMIO_GUEST_PAGE_SIZE) = PAGE_SIZE;
    80208adc:	00003797          	auipc	a5,0x3
    80208ae0:	dac78793          	addi	a5,a5,-596 # 8020b888 <illegal+0x2c8>
    80208ae4:	639c                	ld	a5,0(a5)
    80208ae6:	6705                	lui	a4,0x1
    80208ae8:	c398                	sw	a4,0(a5)

    REGISTER(VIRTIO_MMIO_QUEUE_SEL) = 0;
    80208aea:	00003797          	auipc	a5,0x3
    80208aee:	da678793          	addi	a5,a5,-602 # 8020b890 <illegal+0x2d0>
    80208af2:	639c                	ld	a5,0(a5)
    80208af4:	0007a023          	sw	zero,0(a5)
    uint32_t max = REGISTER(VIRTIO_MMIO_QUEUE_NUM_MAX);
    80208af8:	00003797          	auipc	a5,0x3
    80208afc:	da078793          	addi	a5,a5,-608 # 8020b898 <illegal+0x2d8>
    80208b00:	639c                	ld	a5,0(a5)
    80208b02:	439c                	lw	a5,0(a5)
    80208b04:	fcf42e23          	sw	a5,-36(s0)
    if (max == 0)
    80208b08:	fdc42783          	lw	a5,-36(s0)
    80208b0c:	2781                	sext.w	a5,a5
    80208b0e:	eb91                	bnez	a5,80208b22 <virtio_disk_init+0x1da>
        panic("virtio disk has no queue 0");
    80208b10:	00003517          	auipc	a0,0x3
    80208b14:	ca050513          	addi	a0,a0,-864 # 8020b7b0 <illegal+0x1f0>
    80208b18:	ffffa097          	auipc	ra,0xffffa
    80208b1c:	fec080e7          	jalr	-20(ra) # 80202b04 <panic>
    80208b20:	a005                	j	80208b40 <virtio_disk_init+0x1f8>
    else if (max < VIRTIO_NUM)
    80208b22:	fdc42783          	lw	a5,-36(s0)
    80208b26:	0007871b          	sext.w	a4,a5
    80208b2a:	479d                	li	a5,7
    80208b2c:	00e7ea63          	bltu	a5,a4,80208b40 <virtio_disk_init+0x1f8>
        panic("virtio disk max queue too short");
    80208b30:	00003517          	auipc	a0,0x3
    80208b34:	ca050513          	addi	a0,a0,-864 # 8020b7d0 <illegal+0x210>
    80208b38:	ffffa097          	auipc	ra,0xffffa
    80208b3c:	fcc080e7          	jalr	-52(ra) # 80202b04 <panic>
    REGISTER(VIRTIO_MMIO_QUEUE_NUM) = VIRTIO_NUM;
    80208b40:	00003797          	auipc	a5,0x3
    80208b44:	d6078793          	addi	a5,a5,-672 # 8020b8a0 <illegal+0x2e0>
    80208b48:	639c                	ld	a5,0(a5)
    80208b4a:	4721                	li	a4,8
    80208b4c:	c398                	sw	a4,0(a5)
    memset(disk.pages, 0, sizeof(disk.pages));
    80208b4e:	6609                	lui	a2,0x2
    80208b50:	4581                	li	a1,0
    80208b52:	00326517          	auipc	a0,0x326
    80208b56:	4ae50513          	addi	a0,a0,1198 # 8052f000 <disk>
    80208b5a:	ffffa097          	auipc	ra,0xffffa
    80208b5e:	fcc080e7          	jalr	-52(ra) # 80202b26 <memset>
    REGISTER(VIRTIO_MMIO_QUEUE_PFN) = (address_t)disk.pages >> PAGE_SHIFT;
    80208b62:	00326797          	auipc	a5,0x326
    80208b66:	49e78793          	addi	a5,a5,1182 # 8052f000 <disk>
    80208b6a:	00c7d713          	srli	a4,a5,0xc
    80208b6e:	00003797          	auipc	a5,0x3
    80208b72:	d3a78793          	addi	a5,a5,-710 # 8020b8a8 <illegal+0x2e8>
    80208b76:	639c                	ld	a5,0(a5)
    80208b78:	2701                	sext.w	a4,a4
    80208b7a:	c398                	sw	a4,0(a5)

    disk.desc = (VRingDesc*)disk.pages;
    80208b7c:	00326717          	auipc	a4,0x326
    80208b80:	48470713          	addi	a4,a4,1156 # 8052f000 <disk>
    80208b84:	6789                	lui	a5,0x2
    80208b86:	97ba                	add	a5,a5,a4
    80208b88:	00326717          	auipc	a4,0x326
    80208b8c:	47870713          	addi	a4,a4,1144 # 8052f000 <disk>
    80208b90:	e398                	sd	a4,0(a5)
    disk.avail = (uint16_t*)((char*)disk.desc + VIRTIO_NUM * sizeof(VRingDesc));
    80208b92:	00326717          	auipc	a4,0x326
    80208b96:	46e70713          	addi	a4,a4,1134 # 8052f000 <disk>
    80208b9a:	6789                	lui	a5,0x2
    80208b9c:	97ba                	add	a5,a5,a4
    80208b9e:	639c                	ld	a5,0(a5)
    80208ba0:	08078713          	addi	a4,a5,128 # 2080 <_entry-0x801fdf80>
    80208ba4:	00326697          	auipc	a3,0x326
    80208ba8:	45c68693          	addi	a3,a3,1116 # 8052f000 <disk>
    80208bac:	6789                	lui	a5,0x2
    80208bae:	97b6                	add	a5,a5,a3
    80208bb0:	e798                	sd	a4,8(a5)
    disk.used = (UsedArea*)(disk.pages + PAGE_SIZE);
    80208bb2:	00327717          	auipc	a4,0x327
    80208bb6:	44e70713          	addi	a4,a4,1102 # 80530000 <disk+0x1000>
    80208bba:	00326697          	auipc	a3,0x326
    80208bbe:	44668693          	addi	a3,a3,1094 # 8052f000 <disk>
    80208bc2:	6789                	lui	a5,0x2
    80208bc4:	97b6                	add	a5,a5,a3
    80208bc6:	eb98                	sd	a4,16(a5)

    for (int i = 0; i < VIRTIO_NUM; ++i)
    80208bc8:	fe042623          	sw	zero,-20(s0)
    80208bcc:	a015                	j	80208bf0 <virtio_disk_init+0x2a8>
        disk.free[i] = TRUE;
    80208bce:	00326717          	auipc	a4,0x326
    80208bd2:	43270713          	addi	a4,a4,1074 # 8052f000 <disk>
    80208bd6:	fec42783          	lw	a5,-20(s0)
    80208bda:	97ba                	add	a5,a5,a4
    80208bdc:	6709                	lui	a4,0x2
    80208bde:	97ba                	add	a5,a5,a4
    80208be0:	4705                	li	a4,1
    80208be2:	00e78c23          	sb	a4,24(a5) # 2018 <_entry-0x801fdfe8>
    for (int i = 0; i < VIRTIO_NUM; ++i)
    80208be6:	fec42783          	lw	a5,-20(s0)
    80208bea:	2785                	addiw	a5,a5,1
    80208bec:	fef42623          	sw	a5,-20(s0)
    80208bf0:	fec42783          	lw	a5,-20(s0)
    80208bf4:	0007871b          	sext.w	a4,a5
    80208bf8:	479d                	li	a5,7
    80208bfa:	fce7dae3          	bge	a5,a4,80208bce <virtio_disk_init+0x286>

    __DEBUG_INFO(virtio_disk_init);
    80208bfe:	00003517          	auipc	a0,0x3
    80208c02:	bf250513          	addi	a0,a0,-1038 # 8020b7f0 <illegal+0x230>
    80208c06:	ffffa097          	auipc	ra,0xffffa
    80208c0a:	cec080e7          	jalr	-788(ra) # 802028f2 <printf>
}
    80208c0e:	0001                	nop
    80208c10:	70a2                	ld	ra,40(sp)
    80208c12:	7402                	ld	s0,32(sp)
    80208c14:	6145                	addi	sp,sp,48
    80208c16:	8082                	ret

0000000080208c18 <alloc_desc>:

static int
alloc_desc() {
    80208c18:	1101                	addi	sp,sp,-32
    80208c1a:	ec22                	sd	s0,24(sp)
    80208c1c:	1000                	addi	s0,sp,32
    for (int i = 0; i < VIRTIO_NUM; ++i)
    80208c1e:	fe042623          	sw	zero,-20(s0)
    80208c22:	a081                	j	80208c62 <alloc_desc+0x4a>
        if (disk.free[i]) {
    80208c24:	00326717          	auipc	a4,0x326
    80208c28:	3dc70713          	addi	a4,a4,988 # 8052f000 <disk>
    80208c2c:	fec42783          	lw	a5,-20(s0)
    80208c30:	97ba                	add	a5,a5,a4
    80208c32:	6709                	lui	a4,0x2
    80208c34:	97ba                	add	a5,a5,a4
    80208c36:	0187c783          	lbu	a5,24(a5)
    80208c3a:	cf99                	beqz	a5,80208c58 <alloc_desc+0x40>
            disk.free[i] = FALSE;
    80208c3c:	00326717          	auipc	a4,0x326
    80208c40:	3c470713          	addi	a4,a4,964 # 8052f000 <disk>
    80208c44:	fec42783          	lw	a5,-20(s0)
    80208c48:	97ba                	add	a5,a5,a4
    80208c4a:	6709                	lui	a4,0x2
    80208c4c:	97ba                	add	a5,a5,a4
    80208c4e:	00078c23          	sb	zero,24(a5)
            return i;
    80208c52:	fec42783          	lw	a5,-20(s0)
    80208c56:	a831                	j	80208c72 <alloc_desc+0x5a>
    for (int i = 0; i < VIRTIO_NUM; ++i)
    80208c58:	fec42783          	lw	a5,-20(s0)
    80208c5c:	2785                	addiw	a5,a5,1
    80208c5e:	fef42623          	sw	a5,-20(s0)
    80208c62:	fec42783          	lw	a5,-20(s0)
    80208c66:	0007871b          	sext.w	a4,a5
    80208c6a:	479d                	li	a5,7
    80208c6c:	fae7dce3          	bge	a5,a4,80208c24 <alloc_desc+0xc>
        }
    return -E_NA_DEV;  // TODO
    80208c70:	57c9                	li	a5,-14
}
    80208c72:	853e                	mv	a0,a5
    80208c74:	6462                	ld	s0,24(sp)
    80208c76:	6105                	addi	sp,sp,32
    80208c78:	8082                	ret

0000000080208c7a <free_decs>:

static void
free_decs(int i) {
    80208c7a:	1101                	addi	sp,sp,-32
    80208c7c:	ec06                	sd	ra,24(sp)
    80208c7e:	e822                	sd	s0,16(sp)
    80208c80:	1000                	addi	s0,sp,32
    80208c82:	87aa                	mv	a5,a0
    80208c84:	fef42623          	sw	a5,-20(s0)
    if (i >= VIRTIO_NUM)
    80208c88:	fec42783          	lw	a5,-20(s0)
    80208c8c:	0007871b          	sext.w	a4,a5
    80208c90:	479d                	li	a5,7
    80208c92:	00e7da63          	bge	a5,a4,80208ca6 <free_decs+0x2c>
        panic("virtio_disk_intr 1");
    80208c96:	00003517          	auipc	a0,0x3
    80208c9a:	b7250513          	addi	a0,a0,-1166 # 8020b808 <illegal+0x248>
    80208c9e:	ffffa097          	auipc	ra,0xffffa
    80208ca2:	e66080e7          	jalr	-410(ra) # 80202b04 <panic>
    if (disk.free[i])
    80208ca6:	00326717          	auipc	a4,0x326
    80208caa:	35a70713          	addi	a4,a4,858 # 8052f000 <disk>
    80208cae:	fec42783          	lw	a5,-20(s0)
    80208cb2:	97ba                	add	a5,a5,a4
    80208cb4:	6709                	lui	a4,0x2
    80208cb6:	97ba                	add	a5,a5,a4
    80208cb8:	0187c783          	lbu	a5,24(a5)
    80208cbc:	cb89                	beqz	a5,80208cce <free_decs+0x54>
        panic("virtio_disk_intr 2");
    80208cbe:	00003517          	auipc	a0,0x3
    80208cc2:	b6250513          	addi	a0,a0,-1182 # 8020b820 <illegal+0x260>
    80208cc6:	ffffa097          	auipc	ra,0xffffa
    80208cca:	e3e080e7          	jalr	-450(ra) # 80202b04 <panic>
    disk.desc[i].addr = 0;
    80208cce:	00326717          	auipc	a4,0x326
    80208cd2:	33270713          	addi	a4,a4,818 # 8052f000 <disk>
    80208cd6:	6789                	lui	a5,0x2
    80208cd8:	97ba                	add	a5,a5,a4
    80208cda:	6398                	ld	a4,0(a5)
    80208cdc:	fec42783          	lw	a5,-20(s0)
    80208ce0:	0792                	slli	a5,a5,0x4
    80208ce2:	97ba                	add	a5,a5,a4
    80208ce4:	0007b023          	sd	zero,0(a5) # 2000 <_entry-0x801fe000>
    disk.free[i] = TRUE;
    80208ce8:	00326717          	auipc	a4,0x326
    80208cec:	31870713          	addi	a4,a4,792 # 8052f000 <disk>
    80208cf0:	fec42783          	lw	a5,-20(s0)
    80208cf4:	97ba                	add	a5,a5,a4
    80208cf6:	6709                	lui	a4,0x2
    80208cf8:	97ba                	add	a5,a5,a4
    80208cfa:	4705                	li	a4,1
    80208cfc:	00e78c23          	sb	a4,24(a5)
    proc_wakeupSpin(&disk.free[0]); // TODO此处似乎有可能遇到锁已获取的情况？
    80208d00:	00328517          	auipc	a0,0x328
    80208d04:	31850513          	addi	a0,a0,792 # 80531018 <disk+0x2018>
    80208d08:	ffff9097          	auipc	ra,0xffff9
    80208d0c:	6aa080e7          	jalr	1706(ra) # 802023b2 <proc_wakeupSpin>
}
    80208d10:	0001                	nop
    80208d12:	60e2                	ld	ra,24(sp)
    80208d14:	6442                	ld	s0,16(sp)
    80208d16:	6105                	addi	sp,sp,32
    80208d18:	8082                	ret

0000000080208d1a <free_chain>:

static void
free_chain(int i) {
    80208d1a:	1101                	addi	sp,sp,-32
    80208d1c:	ec06                	sd	ra,24(sp)
    80208d1e:	e822                	sd	s0,16(sp)
    80208d20:	1000                	addi	s0,sp,32
    80208d22:	87aa                	mv	a5,a0
    80208d24:	fef42623          	sw	a5,-20(s0)
    while (1) {
        free_decs(i); // TODO此处似乎有可能遇到锁已获取的情况？
    80208d28:	fec42783          	lw	a5,-20(s0)
    80208d2c:	853e                	mv	a0,a5
    80208d2e:	00000097          	auipc	ra,0x0
    80208d32:	f4c080e7          	jalr	-180(ra) # 80208c7a <free_decs>
        if (disk.desc[i].flags & VRING_DESC_F_NEXT)
    80208d36:	00326717          	auipc	a4,0x326
    80208d3a:	2ca70713          	addi	a4,a4,714 # 8052f000 <disk>
    80208d3e:	6789                	lui	a5,0x2
    80208d40:	97ba                	add	a5,a5,a4
    80208d42:	6398                	ld	a4,0(a5)
    80208d44:	fec42783          	lw	a5,-20(s0)
    80208d48:	0792                	slli	a5,a5,0x4
    80208d4a:	97ba                	add	a5,a5,a4
    80208d4c:	00c7d783          	lhu	a5,12(a5) # 200c <_entry-0x801fdff4>
    80208d50:	2781                	sext.w	a5,a5
    80208d52:	8b85                	andi	a5,a5,1
    80208d54:	2781                	sext.w	a5,a5
    80208d56:	c38d                	beqz	a5,80208d78 <free_chain+0x5e>
            i = disk.desc[i].next;
    80208d58:	00326717          	auipc	a4,0x326
    80208d5c:	2a870713          	addi	a4,a4,680 # 8052f000 <disk>
    80208d60:	6789                	lui	a5,0x2
    80208d62:	97ba                	add	a5,a5,a4
    80208d64:	6398                	ld	a4,0(a5)
    80208d66:	fec42783          	lw	a5,-20(s0)
    80208d6a:	0792                	slli	a5,a5,0x4
    80208d6c:	97ba                	add	a5,a5,a4
    80208d6e:	00e7d783          	lhu	a5,14(a5) # 200e <_entry-0x801fdff2>
    80208d72:	fef42623          	sw	a5,-20(s0)
        free_decs(i); // TODO此处似乎有可能遇到锁已获取的情况？
    80208d76:	bf4d                	j	80208d28 <free_chain+0xe>
        else
            break;
    80208d78:	0001                	nop
    }
}
    80208d7a:	0001                	nop
    80208d7c:	60e2                	ld	ra,24(sp)
    80208d7e:	6442                	ld	s0,16(sp)
    80208d80:	6105                	addi	sp,sp,32
    80208d82:	8082                	ret

0000000080208d84 <alloc3_desc>:

static int
alloc3_desc(int* idx) {
    80208d84:	7139                	addi	sp,sp,-64
    80208d86:	fc06                	sd	ra,56(sp)
    80208d88:	f822                	sd	s0,48(sp)
    80208d8a:	f426                	sd	s1,40(sp)
    80208d8c:	0080                	addi	s0,sp,64
    80208d8e:	fca43423          	sd	a0,-56(s0)
    for (int i = 0; i < 3; ++i) {
    80208d92:	fc042e23          	sw	zero,-36(s0)
    80208d96:	a895                	j	80208e0a <alloc3_desc+0x86>
        idx[i] = alloc_desc();
    80208d98:	fdc42783          	lw	a5,-36(s0)
    80208d9c:	078a                	slli	a5,a5,0x2
    80208d9e:	fc843703          	ld	a4,-56(s0)
    80208da2:	00f704b3          	add	s1,a4,a5
    80208da6:	00000097          	auipc	ra,0x0
    80208daa:	e72080e7          	jalr	-398(ra) # 80208c18 <alloc_desc>
    80208dae:	87aa                	mv	a5,a0
    80208db0:	c09c                	sw	a5,0(s1)
        if (idx[i] < 0) {
    80208db2:	fdc42783          	lw	a5,-36(s0)
    80208db6:	078a                	slli	a5,a5,0x2
    80208db8:	fc843703          	ld	a4,-56(s0)
    80208dbc:	97ba                	add	a5,a5,a4
    80208dbe:	439c                	lw	a5,0(a5)
    80208dc0:	0407d063          	bgez	a5,80208e00 <alloc3_desc+0x7c>
            for (int j = 0; j < i; ++j)
    80208dc4:	fc042c23          	sw	zero,-40(s0)
    80208dc8:	a015                	j	80208dec <alloc3_desc+0x68>
                free_decs(idx[j]);
    80208dca:	fd842783          	lw	a5,-40(s0)
    80208dce:	078a                	slli	a5,a5,0x2
    80208dd0:	fc843703          	ld	a4,-56(s0)
    80208dd4:	97ba                	add	a5,a5,a4
    80208dd6:	439c                	lw	a5,0(a5)
    80208dd8:	853e                	mv	a0,a5
    80208dda:	00000097          	auipc	ra,0x0
    80208dde:	ea0080e7          	jalr	-352(ra) # 80208c7a <free_decs>
            for (int j = 0; j < i; ++j)
    80208de2:	fd842783          	lw	a5,-40(s0)
    80208de6:	2785                	addiw	a5,a5,1
    80208de8:	fcf42c23          	sw	a5,-40(s0)
    80208dec:	fd842703          	lw	a4,-40(s0)
    80208df0:	fdc42783          	lw	a5,-36(s0)
    80208df4:	2701                	sext.w	a4,a4
    80208df6:	2781                	sext.w	a5,a5
    80208df8:	fcf749e3          	blt	a4,a5,80208dca <alloc3_desc+0x46>
            return -E_NA_DEV;  // TODO
    80208dfc:	57c9                	li	a5,-14
    80208dfe:	a831                	j	80208e1a <alloc3_desc+0x96>
    for (int i = 0; i < 3; ++i) {
    80208e00:	fdc42783          	lw	a5,-36(s0)
    80208e04:	2785                	addiw	a5,a5,1
    80208e06:	fcf42e23          	sw	a5,-36(s0)
    80208e0a:	fdc42783          	lw	a5,-36(s0)
    80208e0e:	0007871b          	sext.w	a4,a5
    80208e12:	4789                	li	a5,2
    80208e14:	f8e7d2e3          	bge	a5,a4,80208d98 <alloc3_desc+0x14>
        }
    }
    return 0;
    80208e18:	4781                	li	a5,0
}
    80208e1a:	853e                	mv	a0,a5
    80208e1c:	70e2                	ld	ra,56(sp)
    80208e1e:	7442                	ld	s0,48(sp)
    80208e20:	74a2                	ld	s1,40(sp)
    80208e22:	6121                	addi	sp,sp,64
    80208e24:	8082                	ret

0000000080208e26 <virtio_disk_rw>:

void
virtio_disk_rw(uint8_t* buf, uint32_t secNo, bool write) {
    80208e26:	715d                	addi	sp,sp,-80
    80208e28:	e486                	sd	ra,72(sp)
    80208e2a:	e0a2                	sd	s0,64(sp)
    80208e2c:	fc26                	sd	s1,56(sp)
    80208e2e:	f84a                	sd	s2,48(sp)
    80208e30:	0880                	addi	s0,sp,80
    80208e32:	faa43c23          	sd	a0,-72(s0)
    80208e36:	87ae                	mv	a5,a1
    80208e38:	8732                	mv	a4,a2
    80208e3a:	faf42a23          	sw	a5,-76(s0)
    80208e3e:	87ba                	mv	a5,a4
    80208e40:	faf42823          	sw	a5,-80(s0)
    spinlock_acquire(&disk.vdisk_lk);
    80208e44:	00328517          	auipc	a0,0x328
    80208e48:	26450513          	addi	a0,a0,612 # 805310a8 <disk+0x20a8>
    80208e4c:	ffffc097          	auipc	ra,0xffffc
    80208e50:	b06080e7          	jalr	-1274(ra) # 80204952 <spinlock_acquire>
    {
        int idx[3];
        while (alloc3_desc(idx) != 0)
    80208e54:	a829                	j	80208e6e <virtio_disk_rw+0x48>
            sleep_spin(&disk.free[0], &disk.vdisk_lk);
    80208e56:	00328597          	auipc	a1,0x328
    80208e5a:	25258593          	addi	a1,a1,594 # 805310a8 <disk+0x20a8>
    80208e5e:	00328517          	auipc	a0,0x328
    80208e62:	1ba50513          	addi	a0,a0,442 # 80531018 <disk+0x2018>
    80208e66:	ffff9097          	auipc	ra,0xffff9
    80208e6a:	494080e7          	jalr	1172(ra) # 802022fa <sleep_spin>
        while (alloc3_desc(idx) != 0)
    80208e6e:	fd040793          	addi	a5,s0,-48
    80208e72:	853e                	mv	a0,a5
    80208e74:	00000097          	auipc	ra,0x0
    80208e78:	f10080e7          	jalr	-240(ra) # 80208d84 <alloc3_desc>
    80208e7c:	87aa                	mv	a5,a0
    80208e7e:	ffe1                	bnez	a5,80208e56 <virtio_disk_rw+0x30>
        struct virtio_blk_outhdr {
            uint32_t type;
            uint32_t reserved;
            uint64_t sec;
        } buf0;
        if (write)
    80208e80:	fb042783          	lw	a5,-80(s0)
    80208e84:	2781                	sext.w	a5,a5
    80208e86:	c789                	beqz	a5,80208e90 <virtio_disk_rw+0x6a>
            buf0.type = VIRTIO_BLK_T_OUT;
    80208e88:	4785                	li	a5,1
    80208e8a:	fcf42023          	sw	a5,-64(s0)
    80208e8e:	a019                	j	80208e94 <virtio_disk_rw+0x6e>
        else
            buf0.type = VIRTIO_BLK_T_IN;
    80208e90:	fc042023          	sw	zero,-64(s0)
        buf0.reserved = 0;
    80208e94:	fc042223          	sw	zero,-60(s0)
        buf0.sec = secNo;
    80208e98:	fb446783          	lwu	a5,-76(s0)
    80208e9c:	fcf43423          	sd	a5,-56(s0)
        disk.desc[idx[0]].addr = (address_t)kvm_trans((address_t)&buf0, getCurrentProc()->kpageTable);  // TODO
    80208ea0:	fc040913          	addi	s2,s0,-64
    80208ea4:	ffff9097          	auipc	ra,0xffff9
    80208ea8:	d2a080e7          	jalr	-726(ra) # 80201bce <getCurrentProc>
    80208eac:	87aa                	mv	a5,a0
    80208eae:	7394                	ld	a3,32(a5)
    80208eb0:	00326717          	auipc	a4,0x326
    80208eb4:	15070713          	addi	a4,a4,336 # 8052f000 <disk>
    80208eb8:	6789                	lui	a5,0x2
    80208eba:	97ba                	add	a5,a5,a4
    80208ebc:	6398                	ld	a4,0(a5)
    80208ebe:	fd042783          	lw	a5,-48(s0)
    80208ec2:	0792                	slli	a5,a5,0x4
    80208ec4:	00f704b3          	add	s1,a4,a5
    80208ec8:	85b6                	mv	a1,a3
    80208eca:	854a                	mv	a0,s2
    80208ecc:	ffff8097          	auipc	ra,0xffff8
    80208ed0:	cc8080e7          	jalr	-824(ra) # 80200b94 <kvm_trans>
    80208ed4:	87aa                	mv	a5,a0
    80208ed6:	e09c                	sd	a5,0(s1)
        disk.desc[idx[0]].len = sizeof(buf0);
    80208ed8:	00326717          	auipc	a4,0x326
    80208edc:	12870713          	addi	a4,a4,296 # 8052f000 <disk>
    80208ee0:	6789                	lui	a5,0x2
    80208ee2:	97ba                	add	a5,a5,a4
    80208ee4:	6398                	ld	a4,0(a5)
    80208ee6:	fd042783          	lw	a5,-48(s0)
    80208eea:	0792                	slli	a5,a5,0x4
    80208eec:	97ba                	add	a5,a5,a4
    80208eee:	4741                	li	a4,16
    80208ef0:	c798                	sw	a4,8(a5)
        disk.desc[idx[0]].flags = VRING_DESC_F_NEXT;
    80208ef2:	00326717          	auipc	a4,0x326
    80208ef6:	10e70713          	addi	a4,a4,270 # 8052f000 <disk>
    80208efa:	6789                	lui	a5,0x2
    80208efc:	97ba                	add	a5,a5,a4
    80208efe:	6398                	ld	a4,0(a5)
    80208f00:	fd042783          	lw	a5,-48(s0)
    80208f04:	0792                	slli	a5,a5,0x4
    80208f06:	97ba                	add	a5,a5,a4
    80208f08:	4705                	li	a4,1
    80208f0a:	00e79623          	sh	a4,12(a5) # 200c <_entry-0x801fdff4>
        disk.desc[idx[0]].next = idx[1];
    80208f0e:	fd442683          	lw	a3,-44(s0)
    80208f12:	00326717          	auipc	a4,0x326
    80208f16:	0ee70713          	addi	a4,a4,238 # 8052f000 <disk>
    80208f1a:	6789                	lui	a5,0x2
    80208f1c:	97ba                	add	a5,a5,a4
    80208f1e:	6398                	ld	a4,0(a5)
    80208f20:	fd042783          	lw	a5,-48(s0)
    80208f24:	0792                	slli	a5,a5,0x4
    80208f26:	97ba                	add	a5,a5,a4
    80208f28:	03069713          	slli	a4,a3,0x30
    80208f2c:	9341                	srli	a4,a4,0x30
    80208f2e:	00e79723          	sh	a4,14(a5) # 200e <_entry-0x801fdff2>
        // disk.desc[idx[1]].addr = (address_t)buf_temp;
        disk.desc[idx[1]].addr = (address_t)buf;
    80208f32:	00326717          	auipc	a4,0x326
    80208f36:	0ce70713          	addi	a4,a4,206 # 8052f000 <disk>
    80208f3a:	6789                	lui	a5,0x2
    80208f3c:	97ba                	add	a5,a5,a4
    80208f3e:	6398                	ld	a4,0(a5)
    80208f40:	fd442783          	lw	a5,-44(s0)
    80208f44:	0792                	slli	a5,a5,0x4
    80208f46:	97ba                	add	a5,a5,a4
    80208f48:	fb843703          	ld	a4,-72(s0)
    80208f4c:	e398                	sd	a4,0(a5)
        disk.desc[idx[1]].len = BSIZE;
    80208f4e:	00326717          	auipc	a4,0x326
    80208f52:	0b270713          	addi	a4,a4,178 # 8052f000 <disk>
    80208f56:	6789                	lui	a5,0x2
    80208f58:	97ba                	add	a5,a5,a4
    80208f5a:	6398                	ld	a4,0(a5)
    80208f5c:	fd442783          	lw	a5,-44(s0)
    80208f60:	0792                	slli	a5,a5,0x4
    80208f62:	97ba                	add	a5,a5,a4
    80208f64:	20000713          	li	a4,512
    80208f68:	c798                	sw	a4,8(a5)
        if (write)
    80208f6a:	fb042783          	lw	a5,-80(s0)
    80208f6e:	2781                	sext.w	a5,a5
    80208f70:	cf99                	beqz	a5,80208f8e <virtio_disk_rw+0x168>
            disk.desc[idx[1]].flags = 0;
    80208f72:	00326717          	auipc	a4,0x326
    80208f76:	08e70713          	addi	a4,a4,142 # 8052f000 <disk>
    80208f7a:	6789                	lui	a5,0x2
    80208f7c:	97ba                	add	a5,a5,a4
    80208f7e:	6398                	ld	a4,0(a5)
    80208f80:	fd442783          	lw	a5,-44(s0)
    80208f84:	0792                	slli	a5,a5,0x4
    80208f86:	97ba                	add	a5,a5,a4
    80208f88:	00079623          	sh	zero,12(a5) # 200c <_entry-0x801fdff4>
    80208f8c:	a839                	j	80208faa <virtio_disk_rw+0x184>
        else
            disk.desc[idx[1]].flags = VRING_DESC_F_WRITE;
    80208f8e:	00326717          	auipc	a4,0x326
    80208f92:	07270713          	addi	a4,a4,114 # 8052f000 <disk>
    80208f96:	6789                	lui	a5,0x2
    80208f98:	97ba                	add	a5,a5,a4
    80208f9a:	6398                	ld	a4,0(a5)
    80208f9c:	fd442783          	lw	a5,-44(s0)
    80208fa0:	0792                	slli	a5,a5,0x4
    80208fa2:	97ba                	add	a5,a5,a4
    80208fa4:	4709                	li	a4,2
    80208fa6:	00e79623          	sh	a4,12(a5) # 200c <_entry-0x801fdff4>

        disk.desc[idx[1]].flags |= VRING_DESC_F_NEXT;
    80208faa:	00326717          	auipc	a4,0x326
    80208fae:	05670713          	addi	a4,a4,86 # 8052f000 <disk>
    80208fb2:	6789                	lui	a5,0x2
    80208fb4:	97ba                	add	a5,a5,a4
    80208fb6:	6398                	ld	a4,0(a5)
    80208fb8:	fd442783          	lw	a5,-44(s0)
    80208fbc:	0792                	slli	a5,a5,0x4
    80208fbe:	97ba                	add	a5,a5,a4
    80208fc0:	00c7d703          	lhu	a4,12(a5) # 200c <_entry-0x801fdff4>
    80208fc4:	00326697          	auipc	a3,0x326
    80208fc8:	03c68693          	addi	a3,a3,60 # 8052f000 <disk>
    80208fcc:	6789                	lui	a5,0x2
    80208fce:	97b6                	add	a5,a5,a3
    80208fd0:	6394                	ld	a3,0(a5)
    80208fd2:	fd442783          	lw	a5,-44(s0)
    80208fd6:	0792                	slli	a5,a5,0x4
    80208fd8:	97b6                	add	a5,a5,a3
    80208fda:	00176713          	ori	a4,a4,1
    80208fde:	1742                	slli	a4,a4,0x30
    80208fe0:	9341                	srli	a4,a4,0x30
    80208fe2:	00e79623          	sh	a4,12(a5) # 200c <_entry-0x801fdff4>
        disk.desc[idx[1]].next = idx[2];
    80208fe6:	fd842683          	lw	a3,-40(s0)
    80208fea:	00326717          	auipc	a4,0x326
    80208fee:	01670713          	addi	a4,a4,22 # 8052f000 <disk>
    80208ff2:	6789                	lui	a5,0x2
    80208ff4:	97ba                	add	a5,a5,a4
    80208ff6:	6398                	ld	a4,0(a5)
    80208ff8:	fd442783          	lw	a5,-44(s0)
    80208ffc:	0792                	slli	a5,a5,0x4
    80208ffe:	97ba                	add	a5,a5,a4
    80209000:	03069713          	slli	a4,a3,0x30
    80209004:	9341                	srli	a4,a4,0x30
    80209006:	00e79723          	sh	a4,14(a5) # 200e <_entry-0x801fdff2>

        disk.virt_info[idx[0]].status = 0;
    8020900a:	fd042783          	lw	a5,-48(s0)
    8020900e:	00326717          	auipc	a4,0x326
    80209012:	ff270713          	addi	a4,a4,-14 # 8052f000 <disk>
    80209016:	20278793          	addi	a5,a5,514
    8020901a:	0792                	slli	a5,a5,0x4
    8020901c:	97ba                	add	a5,a5,a4
    8020901e:	00078823          	sb	zero,16(a5)
        disk.desc[idx[2]].addr = (address_t)&disk.virt_info[idx[0]].status;
    80209022:	fd042783          	lw	a5,-48(s0)
    80209026:	20278793          	addi	a5,a5,514
    8020902a:	00479713          	slli	a4,a5,0x4
    8020902e:	00326797          	auipc	a5,0x326
    80209032:	fd278793          	addi	a5,a5,-46 # 8052f000 <disk>
    80209036:	97ba                	add	a5,a5,a4
    80209038:	01078693          	addi	a3,a5,16
    8020903c:	00326717          	auipc	a4,0x326
    80209040:	fc470713          	addi	a4,a4,-60 # 8052f000 <disk>
    80209044:	6789                	lui	a5,0x2
    80209046:	97ba                	add	a5,a5,a4
    80209048:	6398                	ld	a4,0(a5)
    8020904a:	fd842783          	lw	a5,-40(s0)
    8020904e:	0792                	slli	a5,a5,0x4
    80209050:	97ba                	add	a5,a5,a4
    80209052:	8736                	mv	a4,a3
    80209054:	e398                	sd	a4,0(a5)
        disk.desc[idx[2]].len = 1;
    80209056:	00326717          	auipc	a4,0x326
    8020905a:	faa70713          	addi	a4,a4,-86 # 8052f000 <disk>
    8020905e:	6789                	lui	a5,0x2
    80209060:	97ba                	add	a5,a5,a4
    80209062:	6398                	ld	a4,0(a5)
    80209064:	fd842783          	lw	a5,-40(s0)
    80209068:	0792                	slli	a5,a5,0x4
    8020906a:	97ba                	add	a5,a5,a4
    8020906c:	4705                	li	a4,1
    8020906e:	c798                	sw	a4,8(a5)
        disk.desc[idx[2]].flags = VRING_DESC_F_WRITE;
    80209070:	00326717          	auipc	a4,0x326
    80209074:	f9070713          	addi	a4,a4,-112 # 8052f000 <disk>
    80209078:	6789                	lui	a5,0x2
    8020907a:	97ba                	add	a5,a5,a4
    8020907c:	6398                	ld	a4,0(a5)
    8020907e:	fd842783          	lw	a5,-40(s0)
    80209082:	0792                	slli	a5,a5,0x4
    80209084:	97ba                	add	a5,a5,a4
    80209086:	4709                	li	a4,2
    80209088:	00e79623          	sh	a4,12(a5) # 200c <_entry-0x801fdff4>
        disk.desc[idx[2]].next = 0;
    8020908c:	00326717          	auipc	a4,0x326
    80209090:	f7470713          	addi	a4,a4,-140 # 8052f000 <disk>
    80209094:	6789                	lui	a5,0x2
    80209096:	97ba                	add	a5,a5,a4
    80209098:	6398                	ld	a4,0(a5)
    8020909a:	fd842783          	lw	a5,-40(s0)
    8020909e:	0792                	slli	a5,a5,0x4
    802090a0:	97ba                	add	a5,a5,a4
    802090a2:	00079723          	sh	zero,14(a5) # 200e <_entry-0x801fdff2>

        disk.virt_info[idx[0]].buf = buf;
    802090a6:	fd042783          	lw	a5,-48(s0)
    802090aa:	00326717          	auipc	a4,0x326
    802090ae:	f5670713          	addi	a4,a4,-170 # 8052f000 <disk>
    802090b2:	20278793          	addi	a5,a5,514
    802090b6:	0792                	slli	a5,a5,0x4
    802090b8:	97ba                	add	a5,a5,a4
    802090ba:	fb843703          	ld	a4,-72(s0)
    802090be:	e798                	sd	a4,8(a5)
        // disk.virt_info[idx[0]].buf = buf_temp;
        disk.virt_info[idx[0]].disk = 1;
    802090c0:	fd042783          	lw	a5,-48(s0)
    802090c4:	00326717          	auipc	a4,0x326
    802090c8:	f3c70713          	addi	a4,a4,-196 # 8052f000 <disk>
    802090cc:	20278793          	addi	a5,a5,514
    802090d0:	0792                	slli	a5,a5,0x4
    802090d2:	97ba                	add	a5,a5,a4
    802090d4:	4705                	li	a4,1
    802090d6:	cbd8                	sw	a4,20(a5)

        disk.avail[2 + disk.avail[1] % VIRTIO_NUM] = idx[0];
    802090d8:	fd042603          	lw	a2,-48(s0)
    802090dc:	00326717          	auipc	a4,0x326
    802090e0:	f2470713          	addi	a4,a4,-220 # 8052f000 <disk>
    802090e4:	6789                	lui	a5,0x2
    802090e6:	97ba                	add	a5,a5,a4
    802090e8:	6798                	ld	a4,8(a5)
    802090ea:	00326697          	auipc	a3,0x326
    802090ee:	f1668693          	addi	a3,a3,-234 # 8052f000 <disk>
    802090f2:	6789                	lui	a5,0x2
    802090f4:	97b6                	add	a5,a5,a3
    802090f6:	679c                	ld	a5,8(a5)
    802090f8:	0789                	addi	a5,a5,2 # 2002 <_entry-0x801fdffe>
    802090fa:	0007d783          	lhu	a5,0(a5)
    802090fe:	2781                	sext.w	a5,a5
    80209100:	8b9d                	andi	a5,a5,7
    80209102:	2781                	sext.w	a5,a5
    80209104:	2789                	addiw	a5,a5,2
    80209106:	2781                	sext.w	a5,a5
    80209108:	0786                	slli	a5,a5,0x1
    8020910a:	97ba                	add	a5,a5,a4
    8020910c:	03061713          	slli	a4,a2,0x30
    80209110:	9341                	srli	a4,a4,0x30
    80209112:	00e79023          	sh	a4,0(a5)
        __sync_synchronize();
    80209116:	0ff0000f          	fence
        disk.avail[1] += 1;
    8020911a:	00326717          	auipc	a4,0x326
    8020911e:	ee670713          	addi	a4,a4,-282 # 8052f000 <disk>
    80209122:	6789                	lui	a5,0x2
    80209124:	97ba                	add	a5,a5,a4
    80209126:	679c                	ld	a5,8(a5)
    80209128:	0789                	addi	a5,a5,2 # 2002 <_entry-0x801fdffe>
    8020912a:	0007d703          	lhu	a4,0(a5)
    8020912e:	00326697          	auipc	a3,0x326
    80209132:	ed268693          	addi	a3,a3,-302 # 8052f000 <disk>
    80209136:	6789                	lui	a5,0x2
    80209138:	97b6                	add	a5,a5,a3
    8020913a:	679c                	ld	a5,8(a5)
    8020913c:	0789                	addi	a5,a5,2 # 2002 <_entry-0x801fdffe>
    8020913e:	2705                	addiw	a4,a4,1
    80209140:	1742                	slli	a4,a4,0x30
    80209142:	9341                	srli	a4,a4,0x30
    80209144:	00e79023          	sh	a4,0(a5)

        REGISTER(VIRTIO_MMIO_QUEUE_NOTIFY) = 0;
    80209148:	00002797          	auipc	a5,0x2
    8020914c:	76878793          	addi	a5,a5,1896 # 8020b8b0 <illegal+0x2f0>
    80209150:	639c                	ld	a5,0(a5)
    80209152:	0007a023          	sw	zero,0(a5)
        while (disk.virt_info[idx[0]].disk == 1)  // while(bub->disk==1)
    80209156:	a02d                	j	80209180 <virtio_disk_rw+0x35a>
            sleep_spin(disk.virt_info[idx[0]].buf, &disk.vdisk_lk);
    80209158:	fd042783          	lw	a5,-48(s0)
    8020915c:	00326717          	auipc	a4,0x326
    80209160:	ea470713          	addi	a4,a4,-348 # 8052f000 <disk>
    80209164:	20278793          	addi	a5,a5,514
    80209168:	0792                	slli	a5,a5,0x4
    8020916a:	97ba                	add	a5,a5,a4
    8020916c:	679c                	ld	a5,8(a5)
    8020916e:	00328597          	auipc	a1,0x328
    80209172:	f3a58593          	addi	a1,a1,-198 # 805310a8 <disk+0x20a8>
    80209176:	853e                	mv	a0,a5
    80209178:	ffff9097          	auipc	ra,0xffff9
    8020917c:	182080e7          	jalr	386(ra) # 802022fa <sleep_spin>
        while (disk.virt_info[idx[0]].disk == 1)  // while(bub->disk==1)
    80209180:	fd042783          	lw	a5,-48(s0)
    80209184:	00326717          	auipc	a4,0x326
    80209188:	e7c70713          	addi	a4,a4,-388 # 8052f000 <disk>
    8020918c:	20278793          	addi	a5,a5,514
    80209190:	0792                	slli	a5,a5,0x4
    80209192:	97ba                	add	a5,a5,a4
    80209194:	4bdc                	lw	a5,20(a5)
    80209196:	873e                	mv	a4,a5
    80209198:	4785                	li	a5,1
    8020919a:	faf70fe3          	beq	a4,a5,80209158 <virtio_disk_rw+0x332>

        disk.virt_info[idx[0]].buf = NULL;
    8020919e:	fd042783          	lw	a5,-48(s0)
    802091a2:	00326717          	auipc	a4,0x326
    802091a6:	e5e70713          	addi	a4,a4,-418 # 8052f000 <disk>
    802091aa:	20278793          	addi	a5,a5,514
    802091ae:	0792                	slli	a5,a5,0x4
    802091b0:	97ba                	add	a5,a5,a4
    802091b2:	0007b423          	sd	zero,8(a5)
        free_chain(idx[0]); // TODO此处似乎有可能遇到锁已获取的情况？
    802091b6:	fd042783          	lw	a5,-48(s0)
    802091ba:	853e                	mv	a0,a5
    802091bc:	00000097          	auipc	ra,0x0
    802091c0:	b5e080e7          	jalr	-1186(ra) # 80208d1a <free_chain>
    }
    spinlock_release(&disk.vdisk_lk);
    802091c4:	00328517          	auipc	a0,0x328
    802091c8:	ee450513          	addi	a0,a0,-284 # 805310a8 <disk+0x20a8>
    802091cc:	ffffb097          	auipc	ra,0xffffb
    802091d0:	7fc080e7          	jalr	2044(ra) # 802049c8 <spinlock_release>
}
    802091d4:	0001                	nop
    802091d6:	60a6                	ld	ra,72(sp)
    802091d8:	6406                	ld	s0,64(sp)
    802091da:	74e2                	ld	s1,56(sp)
    802091dc:	7942                	ld	s2,48(sp)
    802091de:	6161                	addi	sp,sp,80
    802091e0:	8082                	ret

00000000802091e2 <virtio_disk_intr>:

void
virtio_disk_intr() {
    802091e2:	1101                	addi	sp,sp,-32
    802091e4:	ec06                	sd	ra,24(sp)
    802091e6:	e822                	sd	s0,16(sp)
    802091e8:	1000                	addi	s0,sp,32
    spinlock_acquire(&disk.vdisk_lk);
    802091ea:	00328517          	auipc	a0,0x328
    802091ee:	ebe50513          	addi	a0,a0,-322 # 805310a8 <disk+0x20a8>
    802091f2:	ffffb097          	auipc	ra,0xffffb
    802091f6:	760080e7          	jalr	1888(ra) # 80204952 <spinlock_acquire>
    while ((disk.used_idx % VIRTIO_NUM) != (disk.used->id % VIRTIO_NUM)) {
    802091fa:	a0f9                	j	802092c8 <virtio_disk_intr+0xe6>
        int id = disk.used->elems[disk.used_idx].id;
    802091fc:	00326717          	auipc	a4,0x326
    80209200:	e0470713          	addi	a4,a4,-508 # 8052f000 <disk>
    80209204:	6789                	lui	a5,0x2
    80209206:	97ba                	add	a5,a5,a4
    80209208:	6b98                	ld	a4,16(a5)
    8020920a:	00326697          	auipc	a3,0x326
    8020920e:	df668693          	addi	a3,a3,-522 # 8052f000 <disk>
    80209212:	6789                	lui	a5,0x2
    80209214:	97b6                	add	a5,a5,a3
    80209216:	0207d783          	lhu	a5,32(a5) # 2020 <_entry-0x801fdfe0>
    8020921a:	2781                	sext.w	a5,a5
    8020921c:	078e                	slli	a5,a5,0x3
    8020921e:	97ba                	add	a5,a5,a4
    80209220:	43dc                	lw	a5,4(a5)
    80209222:	fef42623          	sw	a5,-20(s0)
        if (disk.virt_info[id].status != 0)
    80209226:	00326717          	auipc	a4,0x326
    8020922a:	dda70713          	addi	a4,a4,-550 # 8052f000 <disk>
    8020922e:	fec42783          	lw	a5,-20(s0)
    80209232:	20278793          	addi	a5,a5,514
    80209236:	0792                	slli	a5,a5,0x4
    80209238:	97ba                	add	a5,a5,a4
    8020923a:	0107c783          	lbu	a5,16(a5)
    8020923e:	cb89                	beqz	a5,80209250 <virtio_disk_intr+0x6e>
            panic("virtio_disk_intr status error");
    80209240:	00002517          	auipc	a0,0x2
    80209244:	5f850513          	addi	a0,a0,1528 # 8020b838 <illegal+0x278>
    80209248:	ffffa097          	auipc	ra,0xffffa
    8020924c:	8bc080e7          	jalr	-1860(ra) # 80202b04 <panic>
        disk.virt_info[id].disk = 0;
    80209250:	00326717          	auipc	a4,0x326
    80209254:	db070713          	addi	a4,a4,-592 # 8052f000 <disk>
    80209258:	fec42783          	lw	a5,-20(s0)
    8020925c:	20278793          	addi	a5,a5,514
    80209260:	0792                	slli	a5,a5,0x4
    80209262:	97ba                	add	a5,a5,a4
    80209264:	0007aa23          	sw	zero,20(a5)
        proc_wakeupSpin(disk.virt_info[id].buf);  // TODO
    80209268:	00326717          	auipc	a4,0x326
    8020926c:	d9870713          	addi	a4,a4,-616 # 8052f000 <disk>
    80209270:	fec42783          	lw	a5,-20(s0)
    80209274:	20278793          	addi	a5,a5,514
    80209278:	0792                	slli	a5,a5,0x4
    8020927a:	97ba                	add	a5,a5,a4
    8020927c:	679c                	ld	a5,8(a5)
    8020927e:	853e                	mv	a0,a5
    80209280:	ffff9097          	auipc	ra,0xffff9
    80209284:	132080e7          	jalr	306(ra) # 802023b2 <proc_wakeupSpin>

        disk.used_idx = (disk.used_idx + 1) % VIRTIO_NUM;
    80209288:	00326717          	auipc	a4,0x326
    8020928c:	d7870713          	addi	a4,a4,-648 # 8052f000 <disk>
    80209290:	6789                	lui	a5,0x2
    80209292:	97ba                	add	a5,a5,a4
    80209294:	0207d783          	lhu	a5,32(a5) # 2020 <_entry-0x801fdfe0>
    80209298:	2781                	sext.w	a5,a5
    8020929a:	2785                	addiw	a5,a5,1
    8020929c:	2781                	sext.w	a5,a5
    8020929e:	873e                	mv	a4,a5
    802092a0:	41f7579b          	sraiw	a5,a4,0x1f
    802092a4:	01d7d79b          	srliw	a5,a5,0x1d
    802092a8:	9f3d                	addw	a4,a4,a5
    802092aa:	8b1d                	andi	a4,a4,7
    802092ac:	40f707bb          	subw	a5,a4,a5
    802092b0:	2781                	sext.w	a5,a5
    802092b2:	03079713          	slli	a4,a5,0x30
    802092b6:	9341                	srli	a4,a4,0x30
    802092b8:	00326697          	auipc	a3,0x326
    802092bc:	d4868693          	addi	a3,a3,-696 # 8052f000 <disk>
    802092c0:	6789                	lui	a5,0x2
    802092c2:	97b6                	add	a5,a5,a3
    802092c4:	02e79023          	sh	a4,32(a5) # 2020 <_entry-0x801fdfe0>
    while ((disk.used_idx % VIRTIO_NUM) != (disk.used->id % VIRTIO_NUM)) {
    802092c8:	00326717          	auipc	a4,0x326
    802092cc:	d3870713          	addi	a4,a4,-712 # 8052f000 <disk>
    802092d0:	6789                	lui	a5,0x2
    802092d2:	97ba                	add	a5,a5,a4
    802092d4:	0207d703          	lhu	a4,32(a5) # 2020 <_entry-0x801fdfe0>
    802092d8:	00326697          	auipc	a3,0x326
    802092dc:	d2868693          	addi	a3,a3,-728 # 8052f000 <disk>
    802092e0:	6789                	lui	a5,0x2
    802092e2:	97b6                	add	a5,a5,a3
    802092e4:	6b9c                	ld	a5,16(a5)
    802092e6:	0027d783          	lhu	a5,2(a5) # 2002 <_entry-0x801fdffe>
    802092ea:	8fb9                	xor	a5,a5,a4
    802092ec:	17c2                	slli	a5,a5,0x30
    802092ee:	93c1                	srli	a5,a5,0x30
    802092f0:	8b9d                	andi	a5,a5,7
    802092f2:	17c2                	slli	a5,a5,0x30
    802092f4:	93c1                	srli	a5,a5,0x30
    802092f6:	f399                	bnez	a5,802091fc <virtio_disk_intr+0x1a>
    }
    REGISTER(VIRTIO_MMIO_INTERRUPT_ACK) = REGISTER(VIRTIO_MMIO_INTERRUPT_STATUS) & 0x3;
    802092f8:	00002797          	auipc	a5,0x2
    802092fc:	5c078793          	addi	a5,a5,1472 # 8020b8b8 <illegal+0x2f8>
    80209300:	639c                	ld	a5,0(a5)
    80209302:	439c                	lw	a5,0(a5)
    80209304:	0007871b          	sext.w	a4,a5
    80209308:	00002797          	auipc	a5,0x2
    8020930c:	5b878793          	addi	a5,a5,1464 # 8020b8c0 <illegal+0x300>
    80209310:	639c                	ld	a5,0(a5)
    80209312:	8b0d                	andi	a4,a4,3
    80209314:	2701                	sext.w	a4,a4
    80209316:	c398                	sw	a4,0(a5)
    spinlock_release(&disk.vdisk_lk);
    80209318:	00328517          	auipc	a0,0x328
    8020931c:	d9050513          	addi	a0,a0,-624 # 805310a8 <disk+0x20a8>
    80209320:	ffffb097          	auipc	ra,0xffffb
    80209324:	6a8080e7          	jalr	1704(ra) # 802049c8 <spinlock_release>
}
    80209328:	0001                	nop
    8020932a:	60e2                	ld	ra,24(sp)
    8020932c:	6442                	ld	s0,16(sp)
    8020932e:	6105                	addi	sp,sp,32
    80209330:	8082                	ret

0000000080209332 <iobuf_init>:

#include "fs/deffs.h"
#include "fs/iobuf.h"

iobuf_t*
iobuf_init(iobuf_t* iob, void* base, size_t len, offset_t offset) {
    80209332:	7179                	addi	sp,sp,-48
    80209334:	f422                	sd	s0,40(sp)
    80209336:	1800                	addi	s0,sp,48
    80209338:	fea43423          	sd	a0,-24(s0)
    8020933c:	feb43023          	sd	a1,-32(s0)
    80209340:	fcc43c23          	sd	a2,-40(s0)
    80209344:	fcd43823          	sd	a3,-48(s0)
    iob->io_base = base;
    80209348:	fe843783          	ld	a5,-24(s0)
    8020934c:	fe043703          	ld	a4,-32(s0)
    80209350:	e398                	sd	a4,0(a5)
    iob->io_len = iob->io_resid = len;
    80209352:	fe843783          	ld	a5,-24(s0)
    80209356:	fd843703          	ld	a4,-40(s0)
    8020935a:	ef98                	sd	a4,24(a5)
    8020935c:	fe843783          	ld	a5,-24(s0)
    80209360:	6f98                	ld	a4,24(a5)
    80209362:	fe843783          	ld	a5,-24(s0)
    80209366:	eb98                	sd	a4,16(a5)
    iob->io_off = offset;
    80209368:	fe843783          	ld	a5,-24(s0)
    8020936c:	fd043703          	ld	a4,-48(s0)
    80209370:	e798                	sd	a4,8(a5)
    return iob;
    80209372:	fe843783          	ld	a5,-24(s0)
}
    80209376:	853e                	mv	a0,a5
    80209378:	7422                	ld	s0,40(sp)
    8020937a:	6145                	addi	sp,sp,48
    8020937c:	8082                	ret

000000008020937e <iobuf_move>:
 * @param m2b 1 - memory to buffer, 0 - buffer to mem
 * @param copied_store
 * @return int
 */
int
iobuf_move(iobuf_t* iob, void* data, size_t len, bool m2b, size_t* copied_store) {
    8020937e:	715d                	addi	sp,sp,-80
    80209380:	e486                	sd	ra,72(sp)
    80209382:	e0a2                	sd	s0,64(sp)
    80209384:	0880                	addi	s0,sp,80
    80209386:	fca43c23          	sd	a0,-40(s0)
    8020938a:	fcb43823          	sd	a1,-48(s0)
    8020938e:	fcc43423          	sd	a2,-56(s0)
    80209392:	87b6                	mv	a5,a3
    80209394:	fae43c23          	sd	a4,-72(s0)
    80209398:	fcf42223          	sw	a5,-60(s0)
    size_t _len = __MIN(iob->io_resid, len);
    8020939c:	fd843783          	ld	a5,-40(s0)
    802093a0:	6f98                	ld	a4,24(a5)
    802093a2:	fc843783          	ld	a5,-56(s0)
    802093a6:	00f77363          	bgeu	a4,a5,802093ac <iobuf_move+0x2e>
    802093aa:	87ba                	mv	a5,a4
    802093ac:	fef43423          	sd	a5,-24(s0)
    if (_len > 0) {
    802093b0:	fe843783          	ld	a5,-24(s0)
    802093b4:	cfb1                	beqz	a5,80209410 <iobuf_move+0x92>
        if (m2b)  // memory to buffer
    802093b6:	fc442783          	lw	a5,-60(s0)
    802093ba:	2781                	sext.w	a5,a5
    802093bc:	cf91                	beqz	a5,802093d8 <iobuf_move+0x5a>
            memmove(iob->io_base, data, _len);
    802093be:	fd843783          	ld	a5,-40(s0)
    802093c2:	639c                	ld	a5,0(a5)
    802093c4:	fe843603          	ld	a2,-24(s0)
    802093c8:	fd043583          	ld	a1,-48(s0)
    802093cc:	853e                	mv	a0,a5
    802093ce:	ffff9097          	auipc	ra,0xffff9
    802093d2:	7ae080e7          	jalr	1966(ra) # 80202b7c <memmove>
    802093d6:	a829                	j	802093f0 <iobuf_move+0x72>
        else
            memmove(data, iob->io_base, _len);
    802093d8:	fd843783          	ld	a5,-40(s0)
    802093dc:	639c                	ld	a5,0(a5)
    802093de:	fe843603          	ld	a2,-24(s0)
    802093e2:	85be                	mv	a1,a5
    802093e4:	fd043503          	ld	a0,-48(s0)
    802093e8:	ffff9097          	auipc	ra,0xffff9
    802093ec:	794080e7          	jalr	1940(ra) # 80202b7c <memmove>
        iobuf_skip(iob, _len);
    802093f0:	fe843583          	ld	a1,-24(s0)
    802093f4:	fd843503          	ld	a0,-40(s0)
    802093f8:	00000097          	auipc	ra,0x0
    802093fc:	0c8080e7          	jalr	200(ra) # 802094c0 <iobuf_skip>
        len -= _len;
    80209400:	fc843703          	ld	a4,-56(s0)
    80209404:	fe843783          	ld	a5,-24(s0)
    80209408:	40f707b3          	sub	a5,a4,a5
    8020940c:	fcf43423          	sd	a5,-56(s0)
    }
    if (copied_store != NULL)
    80209410:	fb843783          	ld	a5,-72(s0)
    80209414:	c791                	beqz	a5,80209420 <iobuf_move+0xa2>
        *copied_store = _len;
    80209416:	fb843783          	ld	a5,-72(s0)
    8020941a:	fe843703          	ld	a4,-24(s0)
    8020941e:	e398                	sd	a4,0(a5)
    return (len == 0) ? 0 : -E_NO_MEM;
    80209420:	fc843783          	ld	a5,-56(s0)
    80209424:	e399                	bnez	a5,8020942a <iobuf_move+0xac>
    80209426:	4781                	li	a5,0
    80209428:	a011                	j	8020942c <iobuf_move+0xae>
    8020942a:	57f1                	li	a5,-4
}
    8020942c:	853e                	mv	a0,a5
    8020942e:	60a6                	ld	ra,72(sp)
    80209430:	6406                	ld	s0,64(sp)
    80209432:	6161                	addi	sp,sp,80
    80209434:	8082                	ret

0000000080209436 <iobuf_moveZeros>:

int
iobuf_moveZeros(iobuf_t* iob, size_t len, size_t* copied_store) {
    80209436:	7139                	addi	sp,sp,-64
    80209438:	fc06                	sd	ra,56(sp)
    8020943a:	f822                	sd	s0,48(sp)
    8020943c:	0080                	addi	s0,sp,64
    8020943e:	fca43c23          	sd	a0,-40(s0)
    80209442:	fcb43823          	sd	a1,-48(s0)
    80209446:	fcc43423          	sd	a2,-56(s0)
    size_t _len = __MIN(iob->io_resid, len);
    8020944a:	fd843783          	ld	a5,-40(s0)
    8020944e:	6f98                	ld	a4,24(a5)
    80209450:	fd043783          	ld	a5,-48(s0)
    80209454:	00f77363          	bgeu	a4,a5,8020945a <iobuf_moveZeros+0x24>
    80209458:	87ba                	mv	a5,a4
    8020945a:	fef43423          	sd	a5,-24(s0)
    if (_len > 0) {
    8020945e:	fe843783          	ld	a5,-24(s0)
    80209462:	cf85                	beqz	a5,8020949a <iobuf_moveZeros+0x64>
        memset(iob->io_base, 0, _len);
    80209464:	fd843783          	ld	a5,-40(s0)
    80209468:	639c                	ld	a5,0(a5)
    8020946a:	fe843603          	ld	a2,-24(s0)
    8020946e:	4581                	li	a1,0
    80209470:	853e                	mv	a0,a5
    80209472:	ffff9097          	auipc	ra,0xffff9
    80209476:	6b4080e7          	jalr	1716(ra) # 80202b26 <memset>
        iobuf_skip(iob, _len);
    8020947a:	fe843583          	ld	a1,-24(s0)
    8020947e:	fd843503          	ld	a0,-40(s0)
    80209482:	00000097          	auipc	ra,0x0
    80209486:	03e080e7          	jalr	62(ra) # 802094c0 <iobuf_skip>
        len -= _len;
    8020948a:	fd043703          	ld	a4,-48(s0)
    8020948e:	fe843783          	ld	a5,-24(s0)
    80209492:	40f707b3          	sub	a5,a4,a5
    80209496:	fcf43823          	sd	a5,-48(s0)
    }
    if (copied_store != NULL)
    8020949a:	fc843783          	ld	a5,-56(s0)
    8020949e:	c791                	beqz	a5,802094aa <iobuf_moveZeros+0x74>
        *copied_store = _len;
    802094a0:	fc843783          	ld	a5,-56(s0)
    802094a4:	fe843703          	ld	a4,-24(s0)
    802094a8:	e398                	sd	a4,0(a5)
    return (len == 0) ? 0 : E_NO_MEM;
    802094aa:	fd043783          	ld	a5,-48(s0)
    802094ae:	e399                	bnez	a5,802094b4 <iobuf_moveZeros+0x7e>
    802094b0:	4781                	li	a5,0
    802094b2:	a011                	j	802094b6 <iobuf_moveZeros+0x80>
    802094b4:	4791                	li	a5,4
}
    802094b6:	853e                	mv	a0,a5
    802094b8:	70e2                	ld	ra,56(sp)
    802094ba:	7442                	ld	s0,48(sp)
    802094bc:	6121                	addi	sp,sp,64
    802094be:	8082                	ret

00000000802094c0 <iobuf_skip>:

void
iobuf_skip(iobuf_t* iob, size_t n) {
    802094c0:	1101                	addi	sp,sp,-32
    802094c2:	ec22                	sd	s0,24(sp)
    802094c4:	1000                	addi	s0,sp,32
    802094c6:	fea43423          	sd	a0,-24(s0)
    802094ca:	feb43023          	sd	a1,-32(s0)
    iob->io_base += n;
    802094ce:	fe843783          	ld	a5,-24(s0)
    802094d2:	6398                	ld	a4,0(a5)
    802094d4:	fe043783          	ld	a5,-32(s0)
    802094d8:	973e                	add	a4,a4,a5
    802094da:	fe843783          	ld	a5,-24(s0)
    802094de:	e398                	sd	a4,0(a5)
    iob->io_off += n;
    802094e0:	fe843783          	ld	a5,-24(s0)
    802094e4:	679c                	ld	a5,8(a5)
    802094e6:	873e                	mv	a4,a5
    802094e8:	fe043783          	ld	a5,-32(s0)
    802094ec:	97ba                	add	a5,a5,a4
    802094ee:	873e                	mv	a4,a5
    802094f0:	fe843783          	ld	a5,-24(s0)
    802094f4:	e798                	sd	a4,8(a5)
    iob->io_resid -= n;
    802094f6:	fe843783          	ld	a5,-24(s0)
    802094fa:	6f98                	ld	a4,24(a5)
    802094fc:	fe043783          	ld	a5,-32(s0)
    80209500:	8f1d                	sub	a4,a4,a5
    80209502:	fe843783          	ld	a5,-24(s0)
    80209506:	ef98                	sd	a4,24(a5)
    80209508:	0001                	nop
    8020950a:	6462                	ld	s0,24(sp)
    8020950c:	6105                	addi	sp,sp,32
    8020950e:	8082                	ret
	...

000000008020a000 <_trampoline>:
    8020a000:	14051573          	csrrw	a0,sscratch,a0
    8020a004:	02153423          	sd	ra,40(a0)
    8020a008:	02253823          	sd	sp,48(a0)
    8020a00c:	02353c23          	sd	gp,56(a0)
    8020a010:	04453023          	sd	tp,64(a0)
    8020a014:	04553423          	sd	t0,72(a0)
    8020a018:	04653823          	sd	t1,80(a0)
    8020a01c:	04753c23          	sd	t2,88(a0)
    8020a020:	f120                	sd	s0,96(a0)
    8020a022:	f524                	sd	s1,104(a0)
    8020a024:	fd2c                	sd	a1,120(a0)
    8020a026:	e150                	sd	a2,128(a0)
    8020a028:	e554                	sd	a3,136(a0)
    8020a02a:	e958                	sd	a4,144(a0)
    8020a02c:	ed5c                	sd	a5,152(a0)
    8020a02e:	0b053023          	sd	a6,160(a0)
    8020a032:	0b153423          	sd	a7,168(a0)
    8020a036:	0b253823          	sd	s2,176(a0)
    8020a03a:	0b353c23          	sd	s3,184(a0)
    8020a03e:	0d453023          	sd	s4,192(a0)
    8020a042:	0d553423          	sd	s5,200(a0)
    8020a046:	0d653823          	sd	s6,208(a0)
    8020a04a:	0d753c23          	sd	s7,216(a0)
    8020a04e:	0f853023          	sd	s8,224(a0)
    8020a052:	0f953423          	sd	s9,232(a0)
    8020a056:	0fa53823          	sd	s10,240(a0)
    8020a05a:	0fb53c23          	sd	s11,248(a0)
    8020a05e:	11c53023          	sd	t3,256(a0)
    8020a062:	11d53423          	sd	t4,264(a0)
    8020a066:	11e53823          	sd	t5,272(a0)
    8020a06a:	11f53c23          	sd	t6,280(a0)
    8020a06e:	140022f3          	csrr	t0,sscratch
    8020a072:	06553823          	sd	t0,112(a0)
    8020a076:	00853103          	ld	sp,8(a0)
    8020a07a:	02053203          	ld	tp,32(a0)
    8020a07e:	01053283          	ld	t0,16(a0)
    8020a082:	00053303          	ld	t1,0(a0)
    8020a086:	18031073          	csrw	satp,t1
    8020a08a:	12000073          	sfence.vma
    8020a08e:	8282                	jr	t0

000000008020a090 <userret>:
    8020a090:	18059073          	csrw	satp,a1
    8020a094:	12000073          	sfence.vma
    8020a098:	07053283          	ld	t0,112(a0)
    8020a09c:	14029073          	csrw	sscratch,t0
    8020a0a0:	02853083          	ld	ra,40(a0)
    8020a0a4:	03053103          	ld	sp,48(a0)
    8020a0a8:	03853183          	ld	gp,56(a0)
    8020a0ac:	04053203          	ld	tp,64(a0)
    8020a0b0:	04853283          	ld	t0,72(a0)
    8020a0b4:	05053303          	ld	t1,80(a0)
    8020a0b8:	05853383          	ld	t2,88(a0)
    8020a0bc:	7120                	ld	s0,96(a0)
    8020a0be:	7524                	ld	s1,104(a0)
    8020a0c0:	7d2c                	ld	a1,120(a0)
    8020a0c2:	6150                	ld	a2,128(a0)
    8020a0c4:	6554                	ld	a3,136(a0)
    8020a0c6:	6958                	ld	a4,144(a0)
    8020a0c8:	6d5c                	ld	a5,152(a0)
    8020a0ca:	0a053803          	ld	a6,160(a0)
    8020a0ce:	0a853883          	ld	a7,168(a0)
    8020a0d2:	0b053903          	ld	s2,176(a0)
    8020a0d6:	0b853983          	ld	s3,184(a0)
    8020a0da:	0c053a03          	ld	s4,192(a0)
    8020a0de:	0c853a83          	ld	s5,200(a0)
    8020a0e2:	0d053b03          	ld	s6,208(a0)
    8020a0e6:	0d853b83          	ld	s7,216(a0)
    8020a0ea:	0e053c03          	ld	s8,224(a0)
    8020a0ee:	0e853c83          	ld	s9,232(a0)
    8020a0f2:	0f053d03          	ld	s10,240(a0)
    8020a0f6:	0f853d83          	ld	s11,248(a0)
    8020a0fa:	10053e03          	ld	t3,256(a0)
    8020a0fe:	10853e83          	ld	t4,264(a0)
    8020a102:	11053f03          	ld	t5,272(a0)
    8020a106:	11853f83          	ld	t6,280(a0)
    8020a10a:	14051573          	csrrw	a0,sscratch,a0
    8020a10e:	10200073          	sret
	...
